celery: improve fetching of repo_check tasks.
- add refresh link to fail message - introduce proper timeouts so we don't block forever.
This commit is contained in:
parent
c59110bf4c
commit
846af27fc3
3 changed files with 12 additions and 5 deletions
|
|
@ -78,11 +78,15 @@ class RepoChecksView(BaseAppView):
|
|||
|
||||
if task_id and task_id not in ['None']:
|
||||
import rhodecode
|
||||
from rhodecode.lib.celerylib.loader import celery_app
|
||||
from rhodecode.lib.celerylib.loader import celery_app, exceptions
|
||||
if rhodecode.CELERY_ENABLED:
|
||||
log.debug('celery: checking result for task:%s', task_id)
|
||||
task = celery_app.AsyncResult(task_id)
|
||||
task.get()
|
||||
if task.failed():
|
||||
try:
|
||||
task.get(timeout=10)
|
||||
except exceptions.TimeoutError:
|
||||
task = None
|
||||
if task and task.failed():
|
||||
msg = self._log_creation_exception(task.result, repo_name)
|
||||
h.flash(msg, category='error')
|
||||
raise HTTPFound(h.route_path('home'), code=501)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import logging
|
|||
from celery import Celery
|
||||
from celery import signals
|
||||
from celery import Task
|
||||
from celery import exceptions # noqa
|
||||
from kombu.serialization import register
|
||||
from pyramid.threadlocal import get_current_request
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@
|
|||
var url = "${h.route_path('repo_creating_check', repo_name=c.repo_name, _query=dict(task_id=c.task_id))}";
|
||||
$.ajax({
|
||||
url: url,
|
||||
timeout: 60*1000, // sets timeout to 60 seconds
|
||||
complete: function(resp) {
|
||||
if (resp.status == 200) {
|
||||
if (resp.status === 200) {
|
||||
var jsonResponse = resp.responseJSON;
|
||||
|
||||
if (jsonResponse === undefined) {
|
||||
|
|
@ -61,9 +62,10 @@
|
|||
}
|
||||
}
|
||||
else {
|
||||
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);
|
||||
var payload = {
|
||||
message: {
|
||||
message: _gettext('Fetching repository state failed. Error code: {0} {1}. Try refreshing this page.').format(resp.status, resp.statusText),
|
||||
message: message,
|
||||
level: 'error',
|
||||
force: true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue