Fix the queue cleanup worker to delete the items that have expired, not unexpired
This commit is contained in:
parent
7d356c451b
commit
dd0dd39bf0
1 changed files with 3 additions and 4 deletions
|
@ -21,11 +21,10 @@ class QueueCleanupWorker(Worker):
|
|||
""" Performs garbage collection on the queueitem table. """
|
||||
with UseThenDisconnect(app.config):
|
||||
while True:
|
||||
# Find all queue items older than the threshold (typically a week) that have no additional
|
||||
# retries and delete them.
|
||||
# Find all queue items older than the threshold (typically a week) and delete them.
|
||||
threshold_ago = datetime.now() - DELETION_DATE_THRESHOLD
|
||||
to_delete = list(QueueItem.select().where(QueueItem.processing_expires >= threshold_ago,
|
||||
QueueItem.retries_remaining == 0)
|
||||
to_delete = list(QueueItem.select()
|
||||
.where(QueueItem.processing_expires <= threshold_ago)
|
||||
.limit(BATCH_SIZE))
|
||||
|
||||
if len(to_delete) < DELETION_COUNT_THRESHOLD:
|
||||
|
|
Reference in a new issue