|
|
@ -14,6 +14,7 @@ import logging
|
|
|
|
from cPickle import dumps
|
|
|
|
from cPickle import dumps
|
|
|
|
from .queue import Queue, get_failed_queue
|
|
|
|
from .queue import Queue, get_failed_queue
|
|
|
|
from .connections import get_current_connection
|
|
|
|
from .connections import get_current_connection
|
|
|
|
|
|
|
|
from .job import Status
|
|
|
|
from .utils import make_colorizer
|
|
|
|
from .utils import make_colorizer
|
|
|
|
from .exceptions import NoQueueError, UnpickleError
|
|
|
|
from .exceptions import NoQueueError, UnpickleError
|
|
|
|
from .timeouts import death_penalty_after
|
|
|
|
from .timeouts import death_penalty_after
|
|
|
@ -384,12 +385,12 @@ class Worker(object):
|
|
|
|
# Pickle the result in the same try-except block since we need to
|
|
|
|
# Pickle the result in the same try-except block since we need to
|
|
|
|
# use the same exc handling when pickling fails
|
|
|
|
# use the same exc handling when pickling fails
|
|
|
|
pickled_rv = dumps(rv)
|
|
|
|
pickled_rv = dumps(rv)
|
|
|
|
job._status = job.STATUS.finished
|
|
|
|
job._status = Status.FINISHED
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
fq = self.failed_queue
|
|
|
|
fq = self.failed_queue
|
|
|
|
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)
|
|
|
|
job._status = job.STATUS.failed
|
|
|
|
job._status = Status.FAILED
|
|
|
|
|
|
|
|
|
|
|
|
fq.quarantine(job, exc_info=traceback.format_exc())
|
|
|
|
fq.quarantine(job, exc_info=traceback.format_exc())
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -403,9 +404,9 @@ class Worker(object):
|
|
|
|
How long we persist the job result depends on the value of result_ttl:
|
|
|
|
How long we persist the job result depends on the value of result_ttl:
|
|
|
|
- If result_ttl is 0, cleanup the job immediately.
|
|
|
|
- If result_ttl is 0, cleanup the job immediately.
|
|
|
|
- If it's a positive number, set the job to expire in X seconds.
|
|
|
|
- If it's a positive number, set the job to expire in X seconds.
|
|
|
|
- If result_ttl is negative, don't set an expiry to it (persist forever)
|
|
|
|
- If result_ttl is negative, don't set an expiry to it (persist forever)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
result_ttl = self.default_result_ttl if job.result_ttl is None else job.result_ttl
|
|
|
|
result_ttl = self.default_result_ttl if job.result_ttl is None else job.result_ttl
|
|
|
|
if result_ttl == 0:
|
|
|
|
if result_ttl == 0:
|
|
|
|
job.delete()
|
|
|
|
job.delete()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|