##// END OF EJS Templates
celery: fixed bug where celery was not running
dan -
r265:ed0d2e76 default
parent child Browse files
Show More
@@ -248,9 +248,9 b' class ReposController(BaseRepoController'
248 248 task_id = request.GET.get('task_id')
249 249
250 250 if task_id and task_id not in ['None']:
251 from rhodecode import CELERY_ENABLED
251 import rhodecode
252 252 from celery.result import AsyncResult
253 if CELERY_ENABLED:
253 if rhodecode.CELERY_ENABLED:
254 254 task = AsyncResult(task_id)
255 255 if task.failed():
256 256 msg = self._log_creation_exception(task.result, c.repo)
@@ -34,7 +34,6 b' from decorator import decorator'
34 34
35 35 from zope.cachedescriptors.property import Lazy as LazyProperty
36 36
37 from rhodecode import CELERY_ENABLED, CELERY_EAGER
38 37 from rhodecode.config import utils
39 38 from rhodecode.lib.utils2 import safe_str, md5_safe, aslist
40 39 from rhodecode.lib.pidlock import DaemonLock, LockHeld
@@ -54,8 +53,7 b' class ResultWrapper(object):'
54 53
55 54
56 55 def run_task(task, *args, **kwargs):
57 global CELERY_ENABLED
58 if CELERY_ENABLED:
56 if rhodecode.CELERY_ENABLED:
59 57 try:
60 58 t = task.apply_async(args=args, kwargs=kwargs)
61 59 log.info('running task %s:%s', t.task_id, task)
@@ -63,17 +61,17 b' def run_task(task, *args, **kwargs):'
63 61
64 62 except socket.error as e:
65 63 if isinstance(e, IOError) and e.errno == 111:
66 log.debug('Unable to connect to celeryd. Sync execution')
67 CELERY_ENABLED = False
64 log.error('Unable to connect to celeryd. Sync execution')
65 rhodecode.CELERY_ENABLED = False
68 66 else:
69 log.exception("Exception while connecting to celeryd.")
67 log.error("Exception while connecting to celeryd.")
70 68 except KeyError as e:
71 log.debug('Unable to connect to celeryd. Sync execution')
69 log.error('Unable to connect to celeryd. Sync execution')
72 70 except Exception as e:
73 71 log.exception(
74 72 "Exception while trying to run task asynchronous. "
75 73 "Fallback to sync execution.")
76
74 else:
77 75 log.debug('executing task %s in sync mode', task)
78 76 return ResultWrapper(task(*args, **kwargs))
79 77
@@ -106,7 +104,7 b' def locked_task(func):'
106 104
107 105
108 106 def get_session():
109 if CELERY_ENABLED:
107 if rhodecode.CELERY_ENABLED:
110 108 utils.initialize_database(config)
111 109 sa = meta.Session()
112 110 return sa
@@ -118,7 +116,7 b' def dbsession(func):'
118 116 ret = func(*fargs, **fkwargs)
119 117 return ret
120 118 finally:
121 if CELERY_ENABLED and not CELERY_EAGER:
119 if rhodecode.CELERY_ENABLED and not rhodecode.CELERY_EAGER:
122 120 meta.Session.remove()
123 121
124 122 return decorator(__wrapper, func)
@@ -126,7 +124,7 b' def dbsession(func):'
126 124
127 125 def vcsconnection(func):
128 126 def __wrapper(func, *fargs, **fkwargs):
129 if CELERY_ENABLED and not CELERY_EAGER:
127 if rhodecode.CELERY_ENABLED and not rhodecode.CELERY_EAGER:
130 128 backends = config['vcs.backends'] = aslist(
131 129 config.get('vcs.backends', 'hg,git'), sep=',')
132 130 for alias in rhodecode.BACKENDS.keys():
@@ -30,7 +30,7 b' import logging'
30 30 from celery.task import task
31 31 from pylons import config
32 32
33 from rhodecode import CELERY_ENABLED
33 import rhodecode
34 34 from rhodecode.lib.celerylib import (
35 35 run_task, dbsession, __get_lockkey, LockHeld, DaemonLock,
36 36 get_session, vcsconnection)
@@ -45,7 +45,7 b' add_cache(config) # pragma: no cover'
45 45
46 46
47 47 def get_logger(cls):
48 if CELERY_ENABLED:
48 if rhodecode.CELERY_ENABLED:
49 49 try:
50 50 log = cls.get_logger()
51 51 except Exception:
General Comments 0
You need to be logged in to leave comments. Login now