Mercurial > kallithea
changeset 8267:e432a6a7dd7c
celery: move initialization of global kallithea.CELERY_EAGER to the place where we read celery configuration
Prepare for backwards compatibility after the name change with Celery 4.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 24 Feb 2020 18:37:31 +0100 |
parents | b2f7d1c4e001 |
children | f8f50d3b6512 |
files | kallithea/config/app_cfg.py kallithea/lib/celerypylons/__init__.py |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/config/app_cfg.py Mon Feb 24 17:51:17 2020 +0100 +++ b/kallithea/config/app_cfg.py Mon Feb 24 18:37:31 2020 +0100 @@ -161,7 +161,6 @@ # store some globals into kallithea if str2bool(config.get('use_celery')): kallithea.CELERY_APP = celerypylons.make_app() - kallithea.CELERY_EAGER = str2bool(config.get('celery.always.eager')) kallithea.CONFIG = config load_rcextensions(root_path=config['here'])
--- a/kallithea/lib/celerypylons/__init__.py Mon Feb 24 17:51:17 2020 +0100 +++ b/kallithea/lib/celerypylons/__init__.py Mon Feb 24 18:37:31 2020 +0100 @@ -19,12 +19,15 @@ import celery import tg +import kallithea + class CeleryConfig(object): CELERY_IMPORTS = ['kallithea.lib.celerylib.tasks'] CELERY_ACCEPT_CONTENT = ['json'] CELERY_RESULT_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json' + CELERY_ALWAYS_EAGER = False desupported = set([ @@ -37,7 +40,7 @@ log = logging.getLogger(__name__) -def celery_config(config): +def make_celery_config(config): """Return Celery config object populated from relevant settings in a config dict, such as tg.config""" celery_config = CeleryConfig() @@ -68,5 +71,7 @@ def make_app(): """Create celery app from the TurboGears configuration file""" app = celery.Celery() - app.config_from_object(celery_config(tg.config)) + celery_config = make_celery_config(tg.config) + kallithea.CELERY_EAGER = celery_config.CELERY_ALWAYS_EAGER + app.config_from_object(celery_config) return app