Extracted method.

This makes the act of moving failed jobs to the failed queue
responsibility of the FailedQueue itself, not of the Worker.

This fixes #32.
main
Vincent Driessen 13 years ago
parent d64ad225eb
commit 240d2d941d

@ -227,3 +227,14 @@ class FailedQueue(Queue):
def __init__(self): def __init__(self):
super(FailedQueue, self).__init__('failed') super(FailedQueue, self).__init__('failed')
def quarantine(self, job, exc_info):
"""Puts the given Job in quarantine (i.e. put it on the failed
queue).
This is different from normal job enqueueing, since certain meta data
must not be overridden (e.g. `origin` or `enqueued_at`) and other meta
data must be inserted (`ended_at` and `exc_info`).
"""
job.ended_at = times.now()
job.exc_info = exc_info
return self.enqueue_job(job, set_meta_data=False)

@ -3,7 +3,6 @@ import os
import errno import errno
import random import random
import time import time
import times
import procname import procname
import socket import socket
import signal import signal
@ -332,11 +331,7 @@ class Worker(object):
self.log.exception(red(str(e))) self.log.exception(red(str(e)))
self.log.warning('Moving job to %s queue.' % fq.name) self.log.warning('Moving job to %s queue.' % fq.name)
# Store the exception information... fq.quarantine(job, exc_info=traceback.format_exc())
job.ended_at = times.now()
job.exc_info = traceback.format_exc()
fq.enqueue_job(job, set_meta_data=False)
return False return False
else: else:
if rv is None: if rv is None:

Loading…
Cancel
Save