diff --git a/rq/queue.py b/rq/queue.py index 9c33be61..92041ddb 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -108,13 +108,13 @@ class Queue(object): job = Job.for_call(f, *args, **kwargs) return self.enqueue_job(job) - def enqueue_job(self, job, to_failed=False): + def enqueue_job(self, job, set_meta_data=True): """Enqueues a job for delayed execution. - If the `to_failed` argument is `True`, it won't update the origin or - enqueued_at properties. + If the `set_meta_data` argument is `True` (default), it will update + the properties `origin` and `enqueued_at`. """ - if not to_failed: + if set_meta_data: job.origin = self.name job.enqueued_at = times.now() job.save() @@ -221,3 +221,9 @@ class Queue(object): def __str__(self): return '' % (self.name,) + + +class FailedQueue(Queue): + def __init__(self): + super(FailedQueue, self).__init__('failed') + diff --git a/rq/worker.py b/rq/worker.py index 6c4eb430..37e6e128 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -14,7 +14,7 @@ try: Logger = Logger # Does nothing except it shuts up pyflakes annoying error except ImportError: from logging import Logger -from .queue import Queue +from .queue import Queue, FailedQueue from .proxy import conn from .utils import make_colorizer from .exceptions import NoQueueError, UnpickleError @@ -92,7 +92,7 @@ class Worker(object): self._horse_pid = 0 self._stopped = False self.log = Logger('worker') - self.failed_queue = Queue('failed') + self.failed_queue = FailedQueue() def validate_queues(self): # noqa @@ -336,7 +336,7 @@ class Worker(object): job.ended_at = times.now() job.exc_info = traceback.format_exc() - fq.enqueue_job(job, to_failed=True) + fq.enqueue_job(job, set_meta_data=False) return False else: if rv is None: