Changeset - 116151b6bfb2
[Not reviewed]
default
0 8 0
Mads Kiilerich (mads) - 5 years ago 2020-12-30 00:14:57
mads@kiilerich.com
Grafted from: 84df601909c0
celery: drop tracking of task_id - we use ignore_result=True and will never get anything back

There is thus no need for configuration of celery.result_backend .

The alternative would be to fix it. That could give better error reporting from
failing repo creations, but would require quite a bit of additional changes
before it actually works reliably.
8 files changed with 3 insertions and 36 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -259,10 +259,6 @@ use_celery = false
 
## Example: use the message queue on the local virtual host 'kallitheavhost' as the RabbitMQ user 'kallithea':
 
celery.broker_url = amqp://kallithea:thepassword@localhost:5672/kallitheavhost
 

	
 
celery.result_backend = db+sqlite:///celery-results.db
 

	
 
#celery.amqp.task.result.expires = 18000
 

	
 
celery.worker_concurrency = 2
 
celery.worker_max_tasks_per_child = 100
 

	
kallithea/controllers/admin/repos.py
Show inline comments
 
@@ -117,7 +117,6 @@ class ReposController(base.BaseRepoContr
 
            # create is done sometimes async on celery, db transaction
 
            # management is handled there.
 
            task = RepoModel().create(form_result, request.authuser.user_id)
 
            task_id = task.task_id
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            msg = (_('Error creating repository %s')
 
@@ -127,7 +126,7 @@ class ReposController(base.BaseRepoContr
 

	
 
        raise HTTPFound(location=webutils.url('repo_creating_home',
 
                              repo_name=form_result['repo_name_full'],
 
                              task_id=task_id))
 
                              ))
 

	
 
    @NotAnonymous()
 
    def create_repository(self):
 
@@ -158,7 +157,6 @@ class ReposController(base.BaseRepoContr
 
    @LoginRequired()
 
    def repo_creating(self, repo_name):
 
        c.repo = repo_name
 
        c.task_id = request.GET.get('task_id')
 
        if not c.repo:
 
            raise HTTPNotFound()
 
        return base.render('admin/repos/repo_creating.html')
 
@@ -167,14 +165,6 @@ class ReposController(base.BaseRepoContr
 
    @base.jsonify
 
    def repo_check(self, repo_name):
 
        c.repo = repo_name
 
        task_id = request.GET.get('task_id')
 

	
 
        if task_id and task_id not in ['None']:
 
            if kallithea.CELERY_APP:
 
                task_result = kallithea.CELERY_APP.AsyncResult(task_id)
 
                if task_result.failed():
 
                    raise HTTPInternalServerError(task_result.traceback)
 

	
 
        repo = db.Repository.get_by_repo_name(repo_name)
 
        if repo and repo.repo_state == db.Repository.STATE_CREATED:
 
            if repo.clone_uri:
kallithea/controllers/api/api.py
Show inline comments
 
@@ -1266,13 +1266,11 @@ class ApiController(JSONRPCController):
 
            )
 

	
 
            task = RepoModel().create(form_data=data, cur_user=owner.username)
 
            task_id = task.task_id
 
            # no commit, it's done in RepoModel, or async via celery
 
            return dict(
 
                msg="Created new repository `%s`" % (repo_name,),
 
                success=True,  # cannot return the repo data here since fork
 
                               # can be done async
 
                task=task_id
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
@@ -1441,13 +1439,11 @@ class ApiController(JSONRPCController):
 
            )
 
            task = RepoModel().create_fork(form_data, cur_user=owner.username)
 
            # no commit, it's done in RepoModel, or async via celery
 
            task_id = task.task_id
 
            return dict(
 
                msg='Created fork of `%s` as `%s`' % (repo.repo_name,
 
                                                      fork_name),
 
                success=True,  # cannot return the repo data here since fork
 
                               # can be done async
 
                task=task_id
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
kallithea/controllers/forks.py
Show inline comments
 
@@ -143,7 +143,6 @@ class ForksController(base.BaseRepoContr
 
                             repo_groups=c.repo_groups,
 
                             landing_revs=c.landing_revs_choices)()
 
        form_result = {}
 
        task_id = None
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 

	
 
@@ -154,7 +153,6 @@ 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)
 
            task_id = task.task_id
 
        except formencode.Invalid as errors:
 
            return htmlfill.render(
 
                base.render('forks/fork.html'),
 
@@ -170,4 +168,4 @@ class ForksController(base.BaseRepoContr
 

	
 
        raise HTTPFound(location=webutils.url('repo_creating_home',
 
                              repo_name=form_result['repo_name_full'],
 
                              task_id=task_id))
 
                              ))
kallithea/lib/celerylib/__init__.py
Show inline comments
 
@@ -53,8 +53,6 @@ class FakeTask(object):
 

	
 
    traceback = None # if failed
 

	
 
    task_id = None
 

	
 

	
 
def task(f_org):
 
    """Wrapper of celery.task.task, running async if CELERY_APP
kallithea/templates/admin/repos/repo_creating.html
Show inline comments
 
@@ -46,7 +46,7 @@
 
'use strict';
 
(function worker() {
 
  $.ajax({
 
    url: ${h.js(h.url('repo_check_home', repo_name=c.repo_name, repo=c.repo, task_id=c.task_id))},
 
    url: ${h.js(h.url('repo_check_home', repo_name=c.repo_name, repo=c.repo))},
 
    success: function(data) {
 
      if(data.result === true){
 
          //redirect to created fork if our ajax loop tells us to do so.
kallithea/templates/ini/template.ini.mako
Show inline comments
 
@@ -334,10 +334,6 @@ use_celery = false
 
<%text>##</%text> Example: use the message queue on the local virtual host 'kallitheavhost' as the RabbitMQ user 'kallithea':
 
celery.broker_url = amqp://kallithea:thepassword@localhost:5672/kallitheavhost
 

	
 
celery.result_backend = db+sqlite:///celery-results.db
 

	
 
#celery.amqp.task.result.expires = 18000
 

	
 
celery.worker_concurrency = 2
 
celery.worker_max_tasks_per_child = 100
 

	
kallithea/tests/api/api_base.py
Show inline comments
 
@@ -789,7 +789,6 @@ class _BaseTestApi(object):
 
        ret = {
 
            'msg': 'Created new repository `%s`' % repo_name,
 
            'success': True,
 
            'task': None,
 
        }
 
        expected = ret
 
        self._compare_ok(id_, expected, given=response.body)
 
@@ -860,7 +859,6 @@ class _BaseTestApi(object):
 
        expected = {
 
            'msg': 'Created new repository `%s`' % repo_name,
 
            'success': True,
 
            'task': None,
 
        }
 
        self._compare_ok(id_, expected, given=response.body)
 
        repo = RepoModel().get_by_repo_name(repo_name)
 
@@ -893,7 +891,6 @@ class _BaseTestApi(object):
 
        ret = {
 
            'msg': 'Created new repository `%s`' % repo_name,
 
            'success': True,
 
            'task': None,
 
        }
 
        expected = ret
 
        self._compare_ok(id_, expected, given=response.body)
 
@@ -931,7 +928,6 @@ class _BaseTestApi(object):
 
        ret = {
 
            'msg': 'Created new repository `%s`' % repo_name,
 
            'success': True,
 
            'task': None,
 
        }
 
        expected = ret
 
        self._compare_ok(id_, expected, given=response.body)
 
@@ -951,7 +947,6 @@ class _BaseTestApi(object):
 
        ret = {
 
            'msg': 'Created new repository `%s`' % repo_name,
 
            'success': True,
 
            'task': None,
 
        }
 
        expected = ret
 
        self._compare_ok(id_, expected, given=response.body)
 
@@ -1260,7 +1255,6 @@ class _BaseTestApi(object):
 
            'msg': 'Created fork of `%s` as `%s`' % (self.REPO,
 
                                                     fork_name),
 
            'success': True,
 
            'task': None,
 
        }
 
        expected = ret
 
        self._compare_ok(id_, expected, given=response.body)
 
@@ -1281,7 +1275,6 @@ class _BaseTestApi(object):
 
            'msg': 'Created fork of `%s` as `%s`' % (self.REPO,
 
                                                     fork_name),
 
            'success': True,
 
            'task': None,
 
        }
 
        expected = ret
 
        self._compare_ok(id_, expected, given=response.body)
0 comments (0 inline, 0 general)