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. """
|
""" Performs garbage collection on the queueitem table. """
|
||||||
with UseThenDisconnect(app.config):
|
with UseThenDisconnect(app.config):
|
||||||
while True:
|
while True:
|
||||||
# Find all queue items older than the threshold (typically a week) that have no additional
|
# Find all queue items older than the threshold (typically a week) and delete them.
|
||||||
# retries and delete them.
|
|
||||||
threshold_ago = datetime.now() - DELETION_DATE_THRESHOLD
|
threshold_ago = datetime.now() - DELETION_DATE_THRESHOLD
|
||||||
to_delete = list(QueueItem.select().where(QueueItem.processing_expires >= threshold_ago,
|
to_delete = list(QueueItem.select()
|
||||||
QueueItem.retries_remaining == 0)
|
.where(QueueItem.processing_expires <= threshold_ago)
|
||||||
.limit(BATCH_SIZE))
|
.limit(BATCH_SIZE))
|
||||||
|
|
||||||
if len(to_delete) < DELETION_COUNT_THRESHOLD:
|
if len(to_delete) < DELETION_COUNT_THRESHOLD:
|
||||||
|
|
Reference in a new issue