My goal is to retrieve active & reserved tasks on my Celery workers.
I'm using a Django-Celery-Redis framework.
As suggested here: Retrieve list of tasks in a queue in Celery
I have done this to retrieve the tasks:
from your_app.celery import app as my_app
i = my_app.control.inspect()
active_tasks = i.active()
reserved_tasks = i.reserved()
It works well under my local environment.
Online though (I'm using Heroku), it works 5% of the time & 95% of the time I get some errors.
I get two types of errors, that randomly appears:
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: Error 0 connecting to THE_REDIS_SERVER. Error.
Or I get a None
response from my calls.
I tried to configure some timeouts because by default control.inspect
has timeout = 1.0
.
from your_app.celery import app as my_app
i = my_app.control.inspect(timeout = 4.0)
active_tasks = i.active()
reserved_tasks = i.reserved()
But still I get some connection errors.
Any ideas?