|
|
@ -475,9 +475,12 @@ class Worker(object):
|
|
|
|
job execution.
|
|
|
|
job execution.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
with self.connection._pipeline() as pipeline:
|
|
|
|
with self.connection._pipeline() as pipeline:
|
|
|
|
|
|
|
|
timeout = (job.timeout or 180) + 60
|
|
|
|
self.set_state('busy', pipeline=pipeline)
|
|
|
|
self.set_state('busy', pipeline=pipeline)
|
|
|
|
self.set_current_job_id(job.id, pipeline=pipeline)
|
|
|
|
self.set_current_job_id(job.id, pipeline=pipeline)
|
|
|
|
self.heartbeat((job.timeout or 180) + 60, pipeline=pipeline)
|
|
|
|
self.heartbeat(timeout, pipeline=pipeline)
|
|
|
|
|
|
|
|
working_queue = WorkingQueue(job.origin, self.connection)
|
|
|
|
|
|
|
|
working_queue.add(job, timeout, pipeline=pipeline)
|
|
|
|
pipeline.execute()
|
|
|
|
pipeline.execute()
|
|
|
|
|
|
|
|
|
|
|
|
self.procline('Processing %s from %s since %s' % (
|
|
|
|
self.procline('Processing %s from %s since %s' % (
|
|
|
@ -491,13 +494,15 @@ class Worker(object):
|
|
|
|
self.prepare_job_execution(job)
|
|
|
|
self.prepare_job_execution(job)
|
|
|
|
|
|
|
|
|
|
|
|
with self.connection._pipeline() as pipeline:
|
|
|
|
with self.connection._pipeline() as pipeline:
|
|
|
|
|
|
|
|
working_queue = WorkingQueue(job.origin, self.connection)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
job.set_status(Status.STARTED)
|
|
|
|
job.set_status(Status.STARTED)
|
|
|
|
with self.death_penalty_class(job.timeout or self.queue_class.DEFAULT_TIMEOUT):
|
|
|
|
with self.death_penalty_class(job.timeout or self.queue_class.DEFAULT_TIMEOUT):
|
|
|
|
rv = job.perform()
|
|
|
|
rv = job.perform()
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
# use the same exc handling when pickling fails
|
|
|
|
# to use the same exc handling when pickling fails
|
|
|
|
job._result = rv
|
|
|
|
job._result = rv
|
|
|
|
|
|
|
|
|
|
|
|
self.set_current_job_id(None, pipeline=pipeline)
|
|
|
|
self.set_current_job_id(None, pipeline=pipeline)
|
|
|
@ -508,12 +513,14 @@ class Worker(object):
|
|
|
|
job._status = Status.FINISHED
|
|
|
|
job._status = Status.FINISHED
|
|
|
|
job.save(pipeline=pipeline)
|
|
|
|
job.save(pipeline=pipeline)
|
|
|
|
job.cleanup(result_ttl, pipeline=pipeline)
|
|
|
|
job.cleanup(result_ttl, pipeline=pipeline)
|
|
|
|
|
|
|
|
working_queue.remove(job, pipeline=pipeline)
|
|
|
|
|
|
|
|
|
|
|
|
pipeline.execute()
|
|
|
|
pipeline.execute()
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
# Use the public setter here, to immediately update Redis
|
|
|
|
# Use the public setter here, to immediately update Redis
|
|
|
|
job.set_status(Status.FAILED)
|
|
|
|
job.set_status(Status.FAILED)
|
|
|
|
|
|
|
|
working_queue.remove(job)
|
|
|
|
self.handle_exception(job, *sys.exc_info())
|
|
|
|
self.handle_exception(job, *sys.exc_info())
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|