Minor refactoring to make the to-failed queue code a bit more readable.

main
Vincent Driessen 13 years ago
parent 11c7dbb376
commit 1a8b80604d

@ -85,8 +85,13 @@ 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."""
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()

@ -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:

Loading…
Cancel
Save