From fb587297f6cd3dfb6b38163469dcd25fecd95813 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Wed, 15 Feb 2012 23:09:40 +0100 Subject: [PATCH] Requeue should not error when called on a deleted job ID. --- rq/queue.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rq/queue.py b/rq/queue.py index 15bc483..7ec1efe 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -237,7 +237,12 @@ class FailedQueue(Queue): def requeue(self, job_id): """Requeues the given job ID.""" - job = Job.fetch(job_id) + try: + job = Job.fetch(job_id) + except NoSuchJobError: + # Silently ignore/remove this job and return (i.e. do nothing) + conn.lrem(self.key, job_id) + return # Delete it from the FailedQueue (raise an error if that failed) if conn.lrem(self.key, job.id) == 0: