Merge pull request #177 from selwin/master

FailedQueue.requeue should set job status back to Queued
main
Vincent Driessen 12 years ago
commit c0a594d47a

@ -310,6 +310,7 @@ class FailedQueue(Queue):
if self.connection._lrem(self.key, 0, job.id) == 0: if self.connection._lrem(self.key, 0, job.id) == 0:
raise InvalidJobOperationError('Cannot requeue non-failed jobs.') raise InvalidJobOperationError('Cannot requeue non-failed jobs.')
job.status = Status.QUEUED
job.exc_info = None job.exc_info = None
q = Queue(job.origin, connection=self.connection) q = Queue(job.origin, connection=self.connection)
q.enqueue_job(job, timeout=job.timeout) q.enqueue_job(job, timeout=job.timeout)

@ -259,6 +259,16 @@ class TestFailedQueue(RQTestCase):
job = Job.fetch(job.id) job = Job.fetch(job.id)
self.assertEquals(job.timeout, 200) self.assertEquals(job.timeout, 200)
def test_requeue_sets_status_to_queued(self):
"""Requeueing a job should set its status back to QUEUED."""
job = Job.create(func=div_by_zero, args=(1, 2, 3))
job.save()
get_failed_queue().quarantine(job, Exception('Some fake error'))
get_failed_queue().requeue(job.id)
job = Job.fetch(job.id)
self.assertEqual(job.status, Status.QUEUED)
def test_enqueue_preserves_result_ttl(self): def test_enqueue_preserves_result_ttl(self):
"""Enqueueing persists result_ttl.""" """Enqueueing persists result_ttl."""
q = Queue() q = Queue()

Loading…
Cancel
Save