Mercurial > kallithea
changeset 8243:3b1b440b5082
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'.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Thu, 13 Feb 2020 16:41:51 +0100 |
parents | 894a662b12b3 |
children | 046fbed12f70 |
files | kallithea/controllers/admin/repos.py kallithea/lib/celerylib/__init__.py |
diffstat | 2 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/admin/repos.py Thu Feb 13 16:41:51 2020 +0100 +++ b/kallithea/controllers/admin/repos.py Thu Feb 13 16:41:51 2020 +0100 @@ -35,6 +35,7 @@ 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 @@ 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)
--- a/kallithea/lib/celerylib/__init__.py Thu Feb 13 16:41:51 2020 +0100 +++ b/kallithea/lib/celerylib/__init__.py Thu Feb 13 16:41:51 2020 +0100 @@ -68,8 +68,7 @@ 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)