##// END OF EJS Templates
celery: improve fetching of repo_check tasks....
marcink -
r2387:e641eb6b default
parent child Browse files
Show More
@@ -78,11 +78,15 b' class RepoChecksView(BaseAppView):'
78
78
79 if task_id and task_id not in ['None']:
79 if task_id and task_id not in ['None']:
80 import rhodecode
80 import rhodecode
81 from rhodecode.lib.celerylib.loader import celery_app
81 from rhodecode.lib.celerylib.loader import celery_app, exceptions
82 if rhodecode.CELERY_ENABLED:
82 if rhodecode.CELERY_ENABLED:
83 log.debug('celery: checking result for task:%s', task_id)
83 task = celery_app.AsyncResult(task_id)
84 task = celery_app.AsyncResult(task_id)
84 task.get()
85 try:
85 if task.failed():
86 task.get(timeout=10)
87 except exceptions.TimeoutError:
88 task = None
89 if task and task.failed():
86 msg = self._log_creation_exception(task.result, repo_name)
90 msg = self._log_creation_exception(task.result, repo_name)
87 h.flash(msg, category='error')
91 h.flash(msg, category='error')
88 raise HTTPFound(h.route_path('home'), code=501)
92 raise HTTPFound(h.route_path('home'), code=501)
@@ -28,6 +28,7 b' import logging'
28 from celery import Celery
28 from celery import Celery
29 from celery import signals
29 from celery import signals
30 from celery import Task
30 from celery import Task
31 from celery import exceptions # noqa
31 from kombu.serialization import register
32 from kombu.serialization import register
32 from pyramid.threadlocal import get_current_request
33 from pyramid.threadlocal import get_current_request
33
34
@@ -41,8 +41,9 b''
41 var url = "${h.route_path('repo_creating_check', repo_name=c.repo_name, _query=dict(task_id=c.task_id))}";
41 var url = "${h.route_path('repo_creating_check', repo_name=c.repo_name, _query=dict(task_id=c.task_id))}";
42 $.ajax({
42 $.ajax({
43 url: url,
43 url: url,
44 timeout: 60*1000, // sets timeout to 60 seconds
44 complete: function(resp) {
45 complete: function(resp) {
45 if (resp.status == 200) {
46 if (resp.status === 200) {
46 var jsonResponse = resp.responseJSON;
47 var jsonResponse = resp.responseJSON;
47
48
48 if (jsonResponse === undefined) {
49 if (jsonResponse === undefined) {
@@ -61,9 +62,10 b''
61 }
62 }
62 }
63 }
63 else {
64 else {
65 var message = _gettext('Fetching repository state failed. Error code: {0} {1}. Try <a href="{2}">refreshing</a> this page.').format(resp.status, resp.statusText, url);
64 var payload = {
66 var payload = {
65 message: {
67 message: {
66 message: _gettext('Fetching repository state failed. Error code: {0} {1}. Try refreshing this page.').format(resp.status, resp.statusText),
68 message: message,
67 level: 'error',
69 level: 'error',
68 force: true
70 force: true
69 }
71 }
General Comments 0
You need to be logged in to leave comments. Login now