Skip to content

Commit

Permalink
Try with global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Sep 17, 2024
1 parent 4e521fa commit aa9ac04
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/galaxy/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Any,
Callable,
Dict,
Optional,
)

import pebble
Expand Down Expand Up @@ -201,20 +202,26 @@ def wrapper(*args, **kwds):
return decorate


@lru_cache(maxsize=1)
_celery_app: Optional[GalaxyCelery] = None


def get_celery_app() -> GalaxyCelery:
celery_app = GalaxyCelery(
global _celery_app

if _celery_app is not None:
return _celery_app
_celery_app = GalaxyCelery(
"galaxy",
include=TASKS_MODULES,
task_default_queue=DEFAULT_TASK_QUEUE,
task_create_missing_queues=True,
timezone="UTC",
)
celery_app.set_default()
_celery_app.set_default()
config = get_config()
config_celery_app(config, celery_app)
setup_periodic_tasks(config, celery_app)
return celery_app
config_celery_app(config, _celery_app)
setup_periodic_tasks(config, _celery_app)
return _celery_app


def config_celery_app(config, celery_app):
Expand Down

0 comments on commit aa9ac04

Please sign in to comment.