diff --git a/procrastinate/sql/queries.sql b/procrastinate/sql/queries.sql index 234217888..ad91db9d9 100644 --- a/procrastinate/sql/queries.sql +++ b/procrastinate/sql/queries.sql @@ -10,7 +10,7 @@ SELECT procrastinate_defer_job(%(queue)s, %(task_name)s, %(priority)s, %(lock)s, -- defer_periodic_job -- -- Create a periodic job if it doesn't already exist, and delete periodic metadata -- for previous jobs in the same task. -SELECT procrastinate_defer_periodic_job(%(queue)s, %(lock)s, %(queueing_lock)s, %(task_name)s, %(periodic_id)s, %(defer_timestamp)s, %(args)s) AS id; +SELECT procrastinate_defer_periodic_job(%(queue)s, %(lock)s, %(queueing_lock)s, %(task_name)s, %(priority)s, %(periodic_id)s, %(defer_timestamp)s, %(args)s) AS id; -- fetch_job -- -- Get the first awaiting job diff --git a/tests/acceptance/app.py b/tests/acceptance/app.py index 0ffa00a7e..898a35acc 100644 --- a/tests/acceptance/app.py +++ b/tests/acceptance/app.py @@ -122,6 +122,6 @@ def sleep_and_write(sleep, write_before, write_after): @cron_app.periodic(cron="* * * * * *") -@cron_app.task() -def tick(timestamp): - print("tick", next(counter), timestamp) +@cron_app.task(priority=7, pass_context=True) +def tick(context, timestamp): + print("tick", next(counter), context.job.priority, timestamp) diff --git a/tests/acceptance/test_nominal.py b/tests/acceptance/test_nominal.py index 4766edb06..27f32a29a 100644 --- a/tests/acceptance/test_nominal.py +++ b/tests/acceptance/test_nominal.py @@ -188,19 +188,20 @@ def test_queueing_lock(defer, running_worker): def test_periodic_deferrer(worker): # We're launching a worker that executes a periodic task every second, and # letting it run for 2.5 s. It should execute the task 3 times, and print to stdout: - # 0 - # 1 - # 2 (this one won't always be there) + # 0 + # 1 + # 2 (this one won't always be there) stdout, stderr = worker(app="cron_app", sleep=3) # This won't be visible unless the test fails print(stdout) print(stderr) # We're making a dict from the output - results = dict( - (int(a) for a in e[5:].split()) + results = [ + [int(a) for a in e[5:].split()] for e in stdout.splitlines() if e.startswith("tick ") - ) - assert list(results)[:2] == [0, 1] - assert results[1] == results[0] + 1 + ] + assert [row[0] for row in results][:2] == [0, 1] + assert [row[1] for row in results][:2] == [7, 7] + assert results[1][2] == results[0][2] + 1