From c27a6434a8bb6c39938f9292188631bb62a13908 Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Mon, 28 Dec 2015 11:01:50 +0100 Subject: [PATCH 1/2] Set job as finished when not working in async mode --- rq/queue.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rq/queue.py b/rq/queue.py index 162a767..bf2017c 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -217,6 +217,7 @@ class Queue(object): if not self._async: job.perform() + job.set_status(JobStatus.FINISHED) job.save() job.cleanup(DEFAULT_RESULT_TTL) From 89facfada6e0c1f57cc50be6b07bafeaab9d3949 Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Mon, 28 Dec 2015 11:02:27 +0100 Subject: [PATCH 2/2] Test to ensure job is finished in not async mode --- tests/test_job.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_job.py b/tests/test_job.py index 0845259..71bbbea 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -10,7 +10,7 @@ from tests.helpers import strip_microseconds from rq.compat import PY2, as_text from rq.exceptions import NoSuchJobError, UnpickleError -from rq.job import Job, get_current_job +from rq.job import Job, get_current_job, JobStatus from rq.queue import Queue from rq.registry import DeferredJobRegistry from rq.utils import utcformat @@ -307,6 +307,12 @@ class TestJob(RQTestCase): queue = Queue(async=False) queue.enqueue(fixtures.access_self) + def test_job_async_status_finished(self): + queue = Queue(async=False) + job = queue.enqueue(fixtures.say_hello) + self.assertEqual(job.result, 'Hi there, Stranger!') + self.assertEqual(job.get_status(), JobStatus.FINISHED) + def test_get_result_ttl(self): """Getting job result TTL.""" job_result_ttl = 1