I just installed Celery and I want to create a simple status page that shows the current number of workers and their status.
Is this possible? From web searches the best I found was celery.current_app.control.inspect()
But as far as I can see, it doesn't mention anything about workers. (I'm using Kombu with SQS for the backend if that matters)
In the documentation of celery workers it is explained the output of the inspect
commands.
By default using celery.current_app.control.inspect()
returns an "inspector object" that allows you to ask for the state of all the running workers. For example if you execute this code with two running workers named 'adder' and 'sleeper':
i = celery.current_app.control.inspect()
i.registered()
the call to i.registered()
could return something like:
{
'[email protected]': ['tasks.add'],
'[email protected]': ['tasks.sleeptask'],
}
In conclusion, the "inspector" methods registered
, active
, scheduled
, etc. return a dictionary with the results classified by the workers chosen when celery.current_app.control.inspect()
was called (if no workers are passed as arguments, all workers are implicitly selected).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With