Don't enqueue waitlisted jobs on failed execution.

main
Selwin Ong 12 years ago
parent eadc7db29f
commit 6550f86646

@ -123,6 +123,7 @@ class Queue(object):
contain options for RQ itself.
"""
timeout = timeout or self._default_timeout
# TODO: job with dependency shouldn't have "queued" as status
job = Job.create(func, args, kwargs, connection=self.connection,
result_ttl=result_ttl, status=Status.QUEUED,
parent=after)

@ -328,6 +328,7 @@ class Worker(object):
self.connection.expire(self.key, (job.timeout or 180) + 60)
self.fork_and_perform_job(job)
self.connection.expire(self.key, self.default_worker_ttl)
if job.status == 'finished':
queue.enqueue_waitlist(job)
did_perform_work = True

@ -236,6 +236,7 @@ class TestWorker(RQTestCase):
self.assertEqual(job.is_failed, True)
def test_job_dependency(self):
"""Waitlisted jobs are enqueued only if their parents don't fail"""
q = Queue()
w = Worker([q])
parent_job = q.enqueue(say_hello)
@ -243,3 +244,9 @@ class TestWorker(RQTestCase):
w.work(burst=True)
job = Job.fetch(job.id)
self.assertEqual(job.status, 'finished')
parent_job = q.enqueue(div_by_zero)
job = q.enqueue_call(say_hello, after=parent_job)
w.work(burst=True)
job = Job.fetch(job.id)
self.assertNotEqual(job.status, 'finished')

Loading…
Cancel
Save