From e40988f9f877bc8722f8da459203f53a8ac6db50 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Tue, 23 Apr 2024 00:52:05 +0900 Subject: [PATCH] celery_app: set task routes to prevent unnamed queue --- app/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 4092400..49abe67 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -142,11 +142,16 @@ def create_celery() -> Celery: ], related_name=None, ) - created.conf.task_routes = { - "tasks.ocr_task": {"queue": "ocr"}, - "tasks.output_project_task": {"queue": "output"}, - "tasks.import_from_labelplus_task": {"queue": "output"}, - } + created.conf.task_routes = ( + [ + # TODO 'output' should be named better. + # its original purpose was cpu-intensive jobs that may block light ones. + ("tasks.output_project_task", {"queue": "output"}), + ("tasks.import_from_labelplus_task", {"queue": "output"}), + ("tasks.mit.*", {"queue": "mit"}), + ("*", {"queue": "default"}), # default queue for all other tasks + ], + ) return created