Conditions | 6 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
1 | # -*- coding: utf-8 -*- |
||
4 | def get_celery_worker_status(): |
||
5 | error_key = "ERROR" |
||
6 | try: |
||
7 | # noinspection PyUnresolvedReferences |
||
8 | from celery.task.control import inspect |
||
9 | inspection = inspect() |
||
10 | d = inspection.stats() |
||
11 | if not d: |
||
12 | d = {error_key: 'No running Celery workers were found.'} |
||
13 | except IOError as e: |
||
14 | from errno import errorcode |
||
15 | msg = "Error connecting to the backend: " + str(e) |
||
16 | if len(e.args) > 0 and errorcode.get(e.args[0]) == 'ECONNREFUSED': |
||
17 | msg += ' Check that the RabbitMQ server is running.' |
||
18 | d = {error_key: msg} |
||
19 | except ImportError as e: |
||
20 | d = {error_key: str(e)} |
||
21 | return d |
||
22 | |||
25 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.