Changeset - 970ee88be388
[Not reviewed]
default
0 2 0
domruf - 8 years ago 2017-06-11 16:13:09
dominikruf@gmail.com
celery: let celerypylons.app be the actual app, not a factory

Change extracted by Mads Kiilerich.
2 files changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/celerypylons/__init__.py
Show inline comments
 
@@ -8,17 +8,19 @@ the `CELERY_LOADER` environment variable
 
read it. That environment variable must be set *before* importing celery. To
 
ensure that, we wrap celery in this module.
 

	
 
Also, the loader depends on Pylons being configured to it can read the Celery
 
configuration out of it. To make sure that really is the case and give an early
 
We read the configuration from tg.config, thus it must be initialized before
 
loading this module. To make sure that really is the case and give an early
 
warning, we check one of the mandatory settings.
 

	
 
This module must thus not be imported in global scope but must be imported on
 
demand in function scope.
 
demand in function scope after tg.config has been initialized.
 
"""
 

	
 
import os
 
import warnings
 

	
 
import celery.app
 

	
 
# Verify Pylons configuration has been loaded
 
from tg import config
 
assert config['celery.imports'] == 'kallithea.lib.celerylib.tasks', 'Kallithea Celery configuration has not been loaded'
 
@@ -29,8 +31,9 @@ if os.environ.get('CELERY_LOADER', CELER
 
    warnings.warn("'CELERY_LOADER' environment variable will be overridden by celery-pylons.")
 
os.environ['CELERY_LOADER'] = CELERYPYLONS_LOADER
 

	
 
# Import (and expose) celery, thus immediately triggering use of the custom Pylons loader
 
import celery.app as app
 
# Create celery app, thus immediately triggering use of the custom Pylons loader
 
app = celery.app.app_or_default()
 

	
 
import celery.result as result
 
from celery.task import task
 
from celery.bin import worker
kallithea/lib/paster_commands/celeryd.py
Show inline comments
 
@@ -21,7 +21,7 @@ class Command(BasePasterCommand):
 
                            'file before running celeryd')
 

	
 
        from kallithea.lib import celerypylons
 
        cmd = celerypylons.worker.worker(celerypylons.app.app_or_default())
 
        cmd = celerypylons.worker.worker(celerypylons.app)
 

	
 
        celery_args = args.celery_args
 
        if '--' in celery_args:
0 comments (0 inline, 0 general)