Changeset - e432a6a7dd7c
[Not reviewed]
default
0 2 0
Mads Kiilerich - 6 years ago 2020-02-24 18:37:31
mads@kiilerich.com
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.
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/config/app_cfg.py
Show inline comments
 
@@ -161,7 +161,6 @@ def setup_configuration(app):
 
    # 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'])
kallithea/lib/celerypylons/__init__.py
Show inline comments
 
@@ -19,12 +19,15 @@ import logging
 
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 @@ desupported = set([
 
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 celery_config(config):
 
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
0 comments (0 inline, 0 general)