Use the new BgTaskWorkerError exception

This commit is contained in:
tcely 2025-06-06 04:54:13 -04:00 committed by GitHub
parent 687957f21f
commit 7b96b33ed2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,9 +28,9 @@ from background_task import background
from background_task.exceptions import InvalidTaskError from background_task.exceptions import InvalidTaskError
from background_task.models import Task, CompletedTask from background_task.models import Task, CompletedTask
from common.logger import log from common.logger import log
from common.errors import ( NoFormatException, NoMediaException, from common.errors import ( BgTaskWorkerError, DownloadFailedException,
NoThumbnailException, NoFormatException, NoMediaException,
DownloadFailedException, ) NoThumbnailException, )
from common.utils import ( django_queryset_generator as qs_gen, from common.utils import ( django_queryset_generator as qs_gen,
remove_enclosed, ) remove_enclosed, )
from .choices import Val, TaskQueue from .choices import Val, TaskQueue
@ -365,7 +365,7 @@ def wait_for_database_queue():
while Task.objects.unlocked(timezone.now()).filter(queue=Val(TaskQueue.DB)).count() > 0: while Task.objects.unlocked(timezone.now()).filter(queue=Val(TaskQueue.DB)).count() > 0:
time.sleep(5) time.sleep(5)
if worker_down_path.exists() and worker_down_path.is_file(): if worker_down_path.exists() and worker_down_path.is_file():
raise Exception(_('queue worker stopped')) raise BgTaskWorkerError(_('queue worker stopped'))
@background(schedule=dict(priority=20, run_at=30), queue=Val(TaskQueue.NET), remove_existing_tasks=True) @background(schedule=dict(priority=20, run_at=30), queue=Val(TaskQueue.NET), remove_existing_tasks=True)