From 05d744c9afce4d6328092107dc2aa5c4700fdf92 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Wed, 13 Feb 2013 11:50:40 +0700 Subject: [PATCH] Requeuing a job should set its status back to Queued. --- rq/queue.py | 1 + tests/test_queue.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/rq/queue.py b/rq/queue.py index b962b09..2103620 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -309,6 +309,7 @@ class FailedQueue(Queue): if self.connection.lrem(self.key, job.id) == 0: raise InvalidJobOperationError('Cannot requeue non-failed jobs.') + job.status = Status.QUEUED job.exc_info = None q = Queue(job.origin, connection=self.connection) q.enqueue_job(job, timeout=job.timeout) diff --git a/tests/test_queue.py b/tests/test_queue.py index 4a88f65..bd0d378 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -259,6 +259,16 @@ class TestFailedQueue(RQTestCase): job = Job.fetch(job.id) 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): """Enqueueing persists result_ttl.""" q = Queue()