Make `Queue.enqueue_job()` execute immediately if `async=False` (#798)

Currently, the job is being performed inside `enqueue_call()`, which
means that `async=False` has no effect if `enqueue_job()` is called
directly. This commit fixes that.
main
Felipe Lacerda 8 years ago committed by Selwin Ong
parent 1029adaf1b
commit cab89254b5

@ -231,9 +231,6 @@ class Queue(object):
job = self.enqueue_job(job, at_front=at_front) job = self.enqueue_job(job, at_front=at_front)
if not self._async:
job = self.run_job(job)
return job return job
def run_job(self, job): def run_job(self, job):
@ -306,6 +303,9 @@ class Queue(object):
if pipeline is None: if pipeline is None:
pipe.execute() pipe.execute()
if not self._async:
job = self.run_job(job)
return job return job
def enqueue_dependents(self, job, pipeline=None): def enqueue_dependents(self, job, pipeline=None):

@ -322,6 +322,13 @@ class TestJob(RQTestCase):
self.assertEqual(job.result, 'Hi there, Stranger!') self.assertEqual(job.result, 'Hi there, Stranger!')
self.assertEqual(job.get_status(), JobStatus.FINISHED) self.assertEqual(job.get_status(), JobStatus.FINISHED)
def test_enqueue_job_async_status_finished(self):
queue = Queue(async=False)
job = Job.create(func=fixtures.say_hello)
job = queue.enqueue_job(job)
self.assertEqual(job.result, 'Hi there, Stranger!')
self.assertEqual(job.get_status(), JobStatus.FINISHED)
def test_get_result_ttl(self): def test_get_result_ttl(self):
"""Getting job result TTL.""" """Getting job result TTL."""
job_result_ttl = 1 job_result_ttl = 1

Loading…
Cancel
Save