# HG changeset patch # User Mads Kiilerich # Date 2021-01-01 18:04:16 # Node ID aa5cd5e446215cbe6e12345cd5719b1ad8e957b1 # Parent 7a73baa4c66cf00ee12c717923ea264fdebdf1ac celery: always set kallithea.CELERY_APP to a Celery app - it is lazy until it actually is used diff --git a/kallithea/__init__.py b/kallithea/__init__.py --- a/kallithea/__init__.py +++ b/kallithea/__init__.py @@ -30,6 +30,8 @@ Original author and date, and relevant c import platform import sys +import celery + if sys.version_info < (3, 6): raise Exception('Kallithea requires python 3.6 or later') @@ -40,7 +42,7 @@ BACKENDS = { 'git': 'Git repository', } -CELERY_APP = None # set to Celery app instance if using Celery +CELERY_APP = celery.Celery() # needed at import time but is lazy and can be configured later CONFIG = {} # set to tg.config when TG app is initialized and calls app_cfg diff --git a/kallithea/config/app_cfg.py b/kallithea/config/app_cfg.py --- a/kallithea/config/app_cfg.py +++ b/kallithea/config/app_cfg.py @@ -136,7 +136,7 @@ def setup_configuration(app): kallithea.DEFAULT_USER_ID = db.User.get_default_user().user_id if asbool(config.get('use_celery')): - kallithea.CELERY_APP = celery_app.make_app() + kallithea.CELERY_APP.config_from_object(celery_app.make_celery_config(config)) kallithea.CONFIG = config load_extensions(root_path=config['here']) diff --git a/kallithea/lib/celery_app.py b/kallithea/lib/celery_app.py --- a/kallithea/lib/celery_app.py +++ b/kallithea/lib/celery_app.py @@ -16,9 +16,6 @@ mandatory settings. import logging -import celery -import tg - class CeleryConfig(object): imports = ['kallithea.model.async_tasks'] @@ -72,11 +69,3 @@ def make_celery_config(config): celery_value = config_value setattr(celery_config, celery_key, celery_value) return celery_config - - -def make_app(): - """Create celery app from the TurboGears configuration file""" - app = celery.Celery() - celery_config = make_celery_config(tg.config) - app.config_from_object(celery_config) - return app