Mercurial > kallithea
changeset 8827:aa5cd5e44621
celery: always set kallithea.CELERY_APP to a Celery app - it is lazy until it actually is used
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 01 Jan 2021 18:04:16 +0100 |
parents | 7a73baa4c66c |
children | e0f7da1d3c56 |
files | kallithea/__init__.py kallithea/config/app_cfg.py kallithea/lib/celery_app.py |
diffstat | 3 files changed, 4 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/__init__.py Fri Jan 01 20:38:33 2021 +0100 +++ b/kallithea/__init__.py Fri Jan 01 18:04:16 2021 +0100 @@ -30,6 +30,8 @@ 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 @@ '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
--- a/kallithea/config/app_cfg.py Fri Jan 01 20:38:33 2021 +0100 +++ b/kallithea/config/app_cfg.py Fri Jan 01 18:04:16 2021 +0100 @@ -136,7 +136,7 @@ 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'])
--- a/kallithea/lib/celery_app.py Fri Jan 01 20:38:33 2021 +0100 +++ b/kallithea/lib/celery_app.py Fri Jan 01 18:04:16 2021 +0100 @@ -16,9 +16,6 @@ import logging -import celery -import tg - class CeleryConfig(object): imports = ['kallithea.model.async_tasks'] @@ -72,11 +69,3 @@ 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