##// END OF EJS Templates
celery: move initialization of global kallithea.CELERY_EAGER to the place where we read celery configuration...
Mads Kiilerich -
r8136:e432a6a7 default
parent child Browse files
Show More
@@ -161,7 +161,6 b' def setup_configuration(app):'
161 # store some globals into kallithea
161 # store some globals into kallithea
162 if str2bool(config.get('use_celery')):
162 if str2bool(config.get('use_celery')):
163 kallithea.CELERY_APP = celerypylons.make_app()
163 kallithea.CELERY_APP = celerypylons.make_app()
164 kallithea.CELERY_EAGER = str2bool(config.get('celery.always.eager'))
165 kallithea.CONFIG = config
164 kallithea.CONFIG = config
166
165
167 load_rcextensions(root_path=config['here'])
166 load_rcextensions(root_path=config['here'])
@@ -19,12 +19,15 b' import logging'
19 import celery
19 import celery
20 import tg
20 import tg
21
21
22 import kallithea
23
22
24
23 class CeleryConfig(object):
25 class CeleryConfig(object):
24 CELERY_IMPORTS = ['kallithea.lib.celerylib.tasks']
26 CELERY_IMPORTS = ['kallithea.lib.celerylib.tasks']
25 CELERY_ACCEPT_CONTENT = ['json']
27 CELERY_ACCEPT_CONTENT = ['json']
26 CELERY_RESULT_SERIALIZER = 'json'
28 CELERY_RESULT_SERIALIZER = 'json'
27 CELERY_TASK_SERIALIZER = 'json'
29 CELERY_TASK_SERIALIZER = 'json'
30 CELERY_ALWAYS_EAGER = False
28
31
29
32
30 desupported = set([
33 desupported = set([
@@ -37,7 +40,7 b' desupported = set(['
37 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
38
41
39
42
40 def celery_config(config):
43 def make_celery_config(config):
41 """Return Celery config object populated from relevant settings in a config dict, such as tg.config"""
44 """Return Celery config object populated from relevant settings in a config dict, such as tg.config"""
42
45
43 celery_config = CeleryConfig()
46 celery_config = CeleryConfig()
@@ -68,5 +71,7 b' def celery_config(config):'
68 def make_app():
71 def make_app():
69 """Create celery app from the TurboGears configuration file"""
72 """Create celery app from the TurboGears configuration file"""
70 app = celery.Celery()
73 app = celery.Celery()
71 app.config_from_object(celery_config(tg.config))
74 celery_config = make_celery_config(tg.config)
75 kallithea.CELERY_EAGER = celery_config.CELERY_ALWAYS_EAGER
76 app.config_from_object(celery_config)
72 return app
77 return app
General Comments 0
You need to be logged in to leave comments. Login now