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 @@ -116,7 +116,7 @@ class ReposController(base.BaseRepoContr 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 --git a/kallithea/controllers/api/api.py b/kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py +++ b/kallithea/controllers/api/api.py @@ -1265,7 +1265,7 @@ class ApiController(JSONRPCController): 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 @@ class ApiController(JSONRPCController): 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 --git a/kallithea/controllers/forks.py b/kallithea/controllers/forks.py --- a/kallithea/controllers/forks.py +++ b/kallithea/controllers/forks.py @@ -152,7 +152,7 @@ class ForksController(base.BaseRepoContr # 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 --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 @@ -42,18 +42,6 @@ from kallithea.model import meta 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 task(f_org): 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 @@ def task(f_org): 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