diff --git a/.gitignore b/.gitignore index bd41077..fc514a9 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,6 @@ htmlcov/ coverage/ backend/celerybeat-schedule -backend/data/dociva.db \ No newline at end of file +backend/data/dociva.db + +docs/ \ No newline at end of file diff --git a/backend/app/extensions.py b/backend/app/extensions.py index f353128..c9fcf55 100644 --- a/backend/app/extensions.py +++ b/backend/app/extensions.py @@ -13,6 +13,28 @@ talisman = Talisman() celery = Celery() +def import_celery_tasks() -> None: + """Import all Celery task modules so task registration is centralized.""" + import app.tasks.barcode_tasks # noqa: F401 + import app.tasks.compress_image_tasks # noqa: F401 + import app.tasks.compress_tasks # noqa: F401 + import app.tasks.convert_tasks # noqa: F401 + import app.tasks.flowchart_tasks # noqa: F401 + import app.tasks.html_to_pdf_tasks # noqa: F401 + import app.tasks.image_tasks # noqa: F401 + import app.tasks.maintenance_tasks # noqa: F401 + import app.tasks.ocr_tasks # noqa: F401 + import app.tasks.pdf_ai_tasks # noqa: F401 + import app.tasks.pdf_convert_tasks # noqa: F401 + import app.tasks.pdf_editor_tasks # noqa: F401 + import app.tasks.pdf_extra_tasks # noqa: F401 + import app.tasks.pdf_to_excel_tasks # noqa: F401 + import app.tasks.pdf_tools_tasks # noqa: F401 + import app.tasks.qrcode_tasks # noqa: F401 + import app.tasks.removebg_tasks # noqa: F401 + import app.tasks.video_tasks # noqa: F401 + + def init_celery(app): """Initialize Celery with Flask app context.""" celery.conf.broker_url = app.config["CELERY_BROKER_URL"] @@ -63,4 +85,5 @@ def init_celery(app): return self.run(*args, **kwargs) celery.Task = ContextTask + import_celery_tasks() return celery diff --git a/backend/celery_worker.py b/backend/celery_worker.py index fc7752a..f73ecaf 100644 --- a/backend/celery_worker.py +++ b/backend/celery_worker.py @@ -1,22 +1,7 @@ """Celery worker entry point.""" from app import create_app -from app.extensions import celery +from app.extensions import celery, import_celery_tasks app = create_app() -# Import all tasks so Celery discovers them -import app.tasks.convert_tasks # noqa: F401 -import app.tasks.compress_tasks # noqa: F401 -import app.tasks.image_tasks # noqa: F401 -import app.tasks.video_tasks # noqa: F401 -import app.tasks.pdf_tools_tasks # noqa: F401 -import app.tasks.flowchart_tasks # noqa: F401 -import app.tasks.maintenance_tasks # noqa: F401 -import app.tasks.ocr_tasks # noqa: F401 -import app.tasks.removebg_tasks # noqa: F401 -import app.tasks.pdf_editor_tasks # noqa: F401 -import app.tasks.compress_image_tasks # noqa: F401 -import app.tasks.pdf_to_excel_tasks # noqa: F401 -import app.tasks.qrcode_tasks # noqa: F401 -import app.tasks.html_to_pdf_tasks # noqa: F401 -import app.tasks.pdf_ai_tasks # noqa: F401 +import_celery_tasks()