changeset 8823:e3d033042fca

celery: drop task returns - we use ignore_result=True and will never get anything interesting back
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 30 Dec 2020 00:00:41 +0100
parents 116151b6bfb2
children 04c8edacc3a1
files kallithea/controllers/admin/repos.py kallithea/controllers/api/api.py kallithea/controllers/forks.py kallithea/lib/celerylib/__init__.py
diffstat 4 files changed, 5 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- 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')
--- 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,
--- 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'),
--- 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