File tree Expand file tree Collapse file tree 2 files changed +0
-37
lines changed
Expand file tree Collapse file tree 2 files changed +0
-37
lines changed Original file line number Diff line number Diff line change 88
99from apiflask import APIFlask
1010
11- from app .celery_worker import make_celery , celery
1211from app .ro_crates .routes import v1_post_bp , v1_get_bp
1312from app .utils .config import DevelopmentConfig , ProductionConfig , make_celery
1413
Original file line number Diff line number Diff line change 55# Copyright (c) 2025 eScience Lab, The University of Manchester
66
77from celery import Celery
8- from flask import Flask
9-
10-
11- def make_celery (app : Flask = None ) -> Celery :
12- """
13- Create and configure a Celery instance using Flask configuration.
14-
15- :param app: The Flask application. Configuration will be used to initialise Celery.
16- :return: Celery: A configured Celery instance.
17- :raises ValueError: If the Flask configuration values are not provided.
18- """
19- if not app :
20- raise ValueError (
21- "A Flask application instance must be provided to configure Celery."
22- )
23-
24- if "CELERY_RESULT_BACKEND" not in app .config :
25- raise ValueError (
26- "Missing configuration: 'CELERY_RESULT_BACKEND' is not defined in the Flask app config."
27- )
28-
29- if "CELERY_BROKER_URL" not in app .config :
30- raise ValueError (
31- "Missing configuration: 'CELERY_BROKER_URL' is not defined in the Flask app config."
32- )
33-
34- celery_instance = Celery (
35- app .import_name ,
36- backend = app .config ["CELERY_RESULT_BACKEND" ],
37- broker = app .config ["CELERY_BROKER_URL" ],
38- )
39-
40- if app :
41- celery_instance .conf .update (app .config )
42-
43- return celery_instance
448
459
4610celery = Celery ()
You can’t perform that action at this time.
0 commit comments