diff --git a/rq/queue.py b/rq/queue.py index efccff86..3ab16d41 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -85,10 +85,15 @@ class Queue(object): job = Job.for_call(f, *args, **kwargs) return self.enqueue_job(job) - def enqueue_job(self, job): - """Enqueues a job for delayed execution.""" - job.origin = self.name - job.enqueued_at = times.now() + def enqueue_job(self, job, to_failed=False): + """Enqueues a job for delayed execution. + + If the `to_failed` argument is `True`, it won't update the origin or + enqueued_at properties. + """ + if not to_failed: + job.origin = self.name + job.enqueued_at = times.now() job.save() self.push_job_id(job.id) return job diff --git a/rq/worker.py b/rq/worker.py index c56cb533..e3863ed5 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -324,13 +324,7 @@ class Worker(object): job.ended_at = times.now() job.exc_info = traceback.format_exc() - # ------ REFACTOR THIS ------------------------- - job.save() - # ...and put the job on the failed queue - fq.push_job_id(job.id) - # ------ UNTIL HERE ---------------------------- - # (should be as easy as fq.enqueue(job) or so) - + fq.enqueue_job(job, to_failed=True) return False else: if rv is None: