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