Only retry on unhealthy exceptions, not JobException's.

This commit is contained in:
Joseph Schorr 2014-08-10 18:28:20 -04:00
parent 0085041517
commit b9e9064af2

View file

@ -131,12 +131,12 @@ class Worker(object):
except JobException:
logger.warning('An error occurred processing request: %s', current_queue_item.body)
self.mark_current_incomplete()
self.mark_current_incomplete(restore_retry=False)
except WorkerUnhealthyException:
logger.error('The worker has encountered an error and will not take new jobs. Job is being requeued.')
self._stop.set()
self.mark_current_incomplete()
self.mark_current_incomplete(restore_retry=True)
finally:
# Close the db handle periodically
@ -187,10 +187,10 @@ class Worker(object):
while start_status_server_port is not None:
sleep(60)
def mark_current_incomplete(self):
def mark_current_incomplete(self, restore_retry=False):
with self._current_item_lock:
if self.current_queue_item is not None:
self._queue.incomplete(self.current_queue_item, restore_retry=True)
self._queue.incomplete(self.current_queue_item, restore_retry=restore_retry)
self.current_queue_item = None
def mark_current_complete(self):