Mercurial > kallithea
changeset 6801:970ee88be388
celery: let celerypylons.app be the actual app, not a factory
Change extracted by Mads Kiilerich.
author | domruf <dominikruf@gmail.com> |
---|---|
date | Sun, 11 Jun 2017 16:13:09 +0200 |
parents | df5a67678b96 |
children | b9853a3cc254 |
files | kallithea/lib/celerypylons/__init__.py kallithea/lib/paster_commands/celeryd.py |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/celerypylons/__init__.py Sat Aug 12 17:55:58 2017 +0200 +++ b/kallithea/lib/celerypylons/__init__.py Sun Jun 11 16:13:09 2017 +0200 @@ -8,17 +8,19 @@ 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 @@ 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
--- a/kallithea/lib/paster_commands/celeryd.py Sat Aug 12 17:55:58 2017 +0200 +++ b/kallithea/lib/paster_commands/celeryd.py Sun Jun 11 16:13:09 2017 +0200 @@ -21,7 +21,7 @@ '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: