# HG changeset patch # User Mads Kiilerich # Date 1609282841 -3600 # Node ID e3d033042fcadb7949be8e568c681f20570b96cc # Parent 116151b6bfb24333469dcd1b381125af9dd26d90 celery: drop task returns - we use ignore_result=True and will never get anything interesting back diff -r 116151b6bfb2 -r e3d033042fca kallithea/controllers/admin/repos.py --- a/kallithea/controllers/admin/repos.py Wed Dec 30 00:14:57 2020 +0100 +++ b/kallithea/controllers/admin/repos.py Wed Dec 30 00:00:41 2020 +0100 @@ -116,7 +116,7 @@ try: # create is done sometimes async on celery, db transaction # management is handled there. - task = RepoModel().create(form_result, request.authuser.user_id) + RepoModel().create(form_result, request.authuser.user_id) except Exception: log.error(traceback.format_exc()) msg = (_('Error creating repository %s') diff -r 116151b6bfb2 -r e3d033042fca kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py Wed Dec 30 00:14:57 2020 +0100 +++ b/kallithea/controllers/api/api.py Wed Dec 30 00:00:41 2020 +0100 @@ -1265,7 +1265,7 @@ repo_copy_permissions=copy_permissions, ) - task = RepoModel().create(form_data=data, cur_user=owner.username) + RepoModel().create(form_data=data, cur_user=owner.username) # no commit, it's done in RepoModel, or async via celery return dict( msg="Created new repository `%s`" % (repo_name,), @@ -1437,7 +1437,7 @@ update_after_clone=False, fork_parent_id=repo.repo_id, ) - task = RepoModel().create_fork(form_data, cur_user=owner.username) + RepoModel().create_fork(form_data, cur_user=owner.username) # no commit, it's done in RepoModel, or async via celery return dict( msg='Created fork of `%s` as `%s`' % (repo.repo_name, diff -r 116151b6bfb2 -r e3d033042fca kallithea/controllers/forks.py --- a/kallithea/controllers/forks.py Wed Dec 30 00:14:57 2020 +0100 +++ b/kallithea/controllers/forks.py Wed Dec 30 00:00:41 2020 +0100 @@ -152,7 +152,7 @@ # create fork is done sometimes async on celery, db transaction # management is handled there. - task = RepoModel().create_fork(form_result, request.authuser.user_id) + RepoModel().create_fork(form_result, request.authuser.user_id) except formencode.Invalid as errors: return htmlfill.render( base.render('forks/fork.html'), diff -r 116151b6bfb2 -r e3d033042fca kallithea/lib/celerylib/__init__.py --- a/kallithea/lib/celerylib/__init__.py Wed Dec 30 00:14:57 2020 +0100 +++ b/kallithea/lib/celerylib/__init__.py Wed Dec 30 00:00:41 2020 +0100 @@ -42,18 +42,6 @@ log = logging.getLogger(__name__) -class FakeTask(object): - """Fake a sync result to make it look like a finished task""" - - def __init__(self, result): - self.result = result - - def failed(self): - return False - - traceback = None # if failed - - def task(f_org): """Wrapper of celery.task.task, running async if CELERY_APP """ @@ -71,7 +59,6 @@ def f_wrapped(*args, **kwargs): t = runner.apply_async(args=args, kwargs=kwargs) log.info('executing task %s in async mode - id %s', f_org, t.task_id) - return t else: def f_wrapped(*args, **kwargs): log.info('executing task %s in sync', f_org.__name__) @@ -79,8 +66,7 @@ f_org(*args, **kwargs) except Exception as e: log.error('exception executing sync task %s in sync: %r', f_org.__name__, e) - raise # TODO: return this in FakeTask as with async tasks? - return FakeTask(None) + raise # TODO: report errors differently ... and consistently between sync and async return f_wrapped