Merge branch 'bagger'

This commit is contained in:
Joseph Schorr 2014-12-01 12:48:59 -05:00
commit 72d613614d
36 changed files with 1123 additions and 17 deletions

View file

@ -127,12 +127,15 @@ class WorkQueue(object):
incomplete_item_obj.save()
self._currently_processing = False
def extend_processing(self, queue_item, seconds_from_now):
@staticmethod
def extend_processing(queue_item, seconds_from_now, retry_count=None,
minimum_extension=MINIMUM_EXTENSION):
new_expiration = datetime.utcnow() + timedelta(seconds=seconds_from_now)
# Only actually write the new expiration to the db if it moves the expiration some minimum
queue_item_obj = QueueItem.get(QueueItem.id == queue_item.id)
if new_expiration - queue_item_obj.processing_expires > MINIMUM_EXTENSION:
with self._transaction_factory(db):
queue_item_obj.processing_expires = new_expiration
queue_item_obj.save()
if new_expiration - queue_item.processing_expires > minimum_extension:
if retry_count is not None:
queue_item.retries_remaining = retry_count
queue_item.processing_expires = new_expiration
queue_item.save()