Reset Huey tasks from the CLI

This commit is contained in:
tcely 2025-06-15 11:49:10 -04:00 committed by GitHub
parent 98f5d45391
commit 9698489388
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,8 @@ from django.core.management.base import BaseCommand, CommandError # noqa
from django.db.transaction import atomic
from django.utils.translation import gettext_lazy as _
from background_task.models import Task
from django_huey import DJANGO_HUEY
from common.huey import h_q_reset_tasks
from common.logger import log
from sync.models import Source
from sync.tasks import index_source_task, check_source_directory_exists
@ -13,6 +15,8 @@ class Command(BaseCommand):
def handle(self, *args, **options):
log.info('Resettings all tasks...')
for queue_name in (DJANGO_HUEY or {}).get('queues', {}):
h_q_reset_tasks(queue_name)
with atomic(durable=True):
# Delete all tasks
Task.objects.all().delete()