Commit c6868f93 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

improve resilience of queue status, compatibility with multiple worker

parent 26895d38
......@@ -86,7 +86,21 @@ def dummy_task():
def get_queue_status():
inspect = celery.control.inspect()
return dict((k, len(list(getattr(inspect, k)().values())[0])) for k in ['active', 'reserved'])
workers = set()
ret = {'active': 0, 'reserved': 0}
for k in ['active', 'reserved']:
for worker, queue in getattr(inspect, k)().items():
ret[k] += len(queue)
except (
AttributeError, # when no worker
ConnectionResetError, # when rabbitMQ went down
TimeoutError, # when rabbitMQ is not reachable
ret['worker'] = len(workers)
return ret
def run_project_analysis_if_needed(project):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment