##// END OF EJS Templates
celery: always count tasks even if they fail
super-admin -
r4891:2cd8759f default
parent child Browse files
Show More
@@ -63,10 +63,17 b' def run_task(task, *args, **kwargs):'
63
63
64 t = None
64 t = None
65 if rhodecode.CELERY_ENABLED and allow_async:
65 if rhodecode.CELERY_ENABLED and allow_async:
66
67 statsd = StatsdClient.statsd
68 if statsd:
69 task_repr = getattr(task, 'name', task)
70 statsd.incr('rhodecode_celery_task_total', tags=[
71 'task:{}'.format(task_repr)
72 ])
73
66 try:
74 try:
67 t = task.apply_async(args=args, kwargs=kwargs)
75 t = task.apply_async(args=args, kwargs=kwargs)
68 log.debug('executing task %s:%s in async mode', t.task_id, task)
76 log.debug('executing task %s:%s in async mode', t.task_id, task)
69 exec_mode = 'async'
70 except socket.error as e:
77 except socket.error as e:
71 if isinstance(e, IOError) and e.errno == 111:
78 if isinstance(e, IOError) and e.errno == 111:
72 log.error('Unable to connect to celeryd `%s`. Sync execution', e)
79 log.error('Unable to connect to celeryd `%s`. Sync execution', e)
@@ -82,14 +89,6 b' def run_task(task, *args, **kwargs):'
82 else:
89 else:
83 log.debug('executing task %s:%s in sync mode', 'TASK', task)
90 log.debug('executing task %s:%s in sync mode', 'TASK', task)
84
91
85 statsd = StatsdClient.statsd
86 if statsd:
87 task_repr = getattr(task, 'name', task)
88 statsd.incr('rhodecode_celery_task_total', tags=[
89 'task:{}'.format(task_repr),
90 'mode:{}'.format(exec_mode)
91 ])
92
93 # we got async task, return it after statsd call
92 # we got async task, return it after statsd call
94 if t:
93 if t:
95 return t
94 return t
General Comments 0
You need to be logged in to leave comments. Login now