Skip to content

Commit

Permalink
Merge pull request rq#177 from selwin/master
Browse files Browse the repository at this point in the history
FailedQueue.requeue should set job status back to Queued
  • Loading branch information
nvie committed Feb 13, 2013
2 parents 4688498 + e5fa82a commit c0a594d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions rq/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def requeue(self, job_id):
if self.connection._lrem(self.key, 0, 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)
10 changes: 10 additions & 0 deletions tests/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ def test_requeueing_preserves_timeout(self):
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()
Expand Down

0 comments on commit c0a594d

Please sign in to comment.