# HG changeset patch # User Mads Kiilerich # Date 2020-02-13 16:41:51 # Node ID 3b1b440b5082bfeeb2ebcfdcbc07916b09386865 # Parent 894a662b12b3ab3e972fa75bd3080d6afed9efba celery: use the proper configured global app for scheduling and retrieving tasks 193138922d56 broke celery, due to magic dependencies on initialization and setting global configuration at import time. Instead, always use the correctly configured global Celery app, both when creating tasks and checking result status. This has been tested to work on Python 3.6 - for example for sending mails and forking repos. Celery has however been found to not work on Python 3.7, due to Celery 3.x using the new reserved keyword 'async'. diff --git a/kallithea/controllers/admin/repos.py b/kallithea/controllers/admin/repos.py --- a/kallithea/controllers/admin/repos.py +++ b/kallithea/controllers/admin/repos.py @@ -35,6 +35,7 @@ from tg import tmpl_context as c from tg.i18n import ugettext as _ from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound +import kallithea from kallithea.config.routing import url from kallithea.lib import helpers as h from kallithea.lib.auth import HasPermissionAny, HasRepoPermissionLevelDecorator, LoginRequired, NotAnonymous @@ -183,7 +184,7 @@ class ReposController(BaseRepoController if task_id and task_id not in ['None']: from kallithea.lib import celerypylons if kallithea.CELERY_APP: - task_result = celerypylons.result.AsyncResult(task_id) + task_result = celerypylons.result.AsyncResult(task_id, app=kallithea.CELERY_APP) if task_result.failed(): raise HTTPInternalServerError(task_result.traceback) diff --git a/kallithea/lib/celerylib/__init__.py b/kallithea/lib/celerylib/__init__.py --- a/kallithea/lib/celerylib/__init__.py +++ b/kallithea/lib/celerylib/__init__.py @@ -68,8 +68,7 @@ def task(f_org): finally: log.info('executed %s task', f_org.__name__) f_async.__name__ = f_org.__name__ - from kallithea.lib import celerypylons - runner = celerypylons.task(ignore_result=True)(f_async) + runner = kallithea.CELERY_APP.task(ignore_result=True)(f_async) def f_wrapped(*args, **kwargs): t = runner.apply_async(args=args, kwargs=kwargs)