Mercurial > kallithea
comparison rhodecode/lib/celerylib/__init__.py @ 1976:a76e9bacbedc beta
garden
- unified logging formatting to use only %
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 02 Feb 2012 00:31:00 +0200 |
parents | a69573cfcb00 |
children | 324ac367a4da |
comparison
equal
deleted
inserted
replaced
1975:9c5b33c4de4d | 1976:a76e9bacbedc |
---|---|
60 | 60 |
61 def run_task(task, *args, **kwargs): | 61 def run_task(task, *args, **kwargs): |
62 if CELERY_ON: | 62 if CELERY_ON: |
63 try: | 63 try: |
64 t = task.apply_async(args=args, kwargs=kwargs) | 64 t = task.apply_async(args=args, kwargs=kwargs) |
65 log.info('running task %s:%s', t.task_id, task) | 65 log.info('running task %s:%s' % (t.task_id, task)) |
66 return t | 66 return t |
67 | 67 |
68 except socket.error, e: | 68 except socket.error, e: |
69 if isinstance(e, IOError) and e.errno == 111: | 69 if isinstance(e, IOError) and e.errno == 111: |
70 log.debug('Unable to connect to celeryd. Sync execution') | 70 log.debug('Unable to connect to celeryd. Sync execution') |
73 except KeyError, e: | 73 except KeyError, e: |
74 log.debug('Unable to connect to celeryd. Sync execution') | 74 log.debug('Unable to connect to celeryd. Sync execution') |
75 except Exception, e: | 75 except Exception, e: |
76 log.error(traceback.format_exc()) | 76 log.error(traceback.format_exc()) |
77 | 77 |
78 log.debug('executing task %s in sync mode', task) | 78 log.debug('executing task %s in sync mode' % task) |
79 return ResultWrapper(task(*args, **kwargs)) | 79 return ResultWrapper(task(*args, **kwargs)) |
80 | 80 |
81 | 81 |
82 def __get_lockkey(func, *fargs, **fkwargs): | 82 def __get_lockkey(func, *fargs, **fkwargs): |
83 params = list(fargs) | 83 params = list(fargs) |
93 def locked_task(func): | 93 def locked_task(func): |
94 def __wrapper(func, *fargs, **fkwargs): | 94 def __wrapper(func, *fargs, **fkwargs): |
95 lockkey = __get_lockkey(func, *fargs, **fkwargs) | 95 lockkey = __get_lockkey(func, *fargs, **fkwargs) |
96 lockkey_path = config['here'] | 96 lockkey_path = config['here'] |
97 | 97 |
98 log.info('running task with lockkey %s', lockkey) | 98 log.info('running task with lockkey %s' % lockkey) |
99 try: | 99 try: |
100 l = DaemonLock(file_=jn(lockkey_path, lockkey)) | 100 l = DaemonLock(file_=jn(lockkey_path, lockkey)) |
101 ret = func(*fargs, **fkwargs) | 101 ret = func(*fargs, **fkwargs) |
102 l.release() | 102 l.release() |
103 return ret | 103 return ret |