Retrieve List of Tasks in a Queue in Celery

How to list the queued items in celery?

If you want to get all scheduled tasks,

celery inspect scheduled

To find all active queues

celery inspect active_queues

For status

celery inspect stats

For all commands

celery inspect

If you want to get it explicitily.Since you are using redis as queue.Then

redis-cli

>KEYS * #find all keys

Then find out something related to celery

>LLEN KEY # i think it gives length of list

How to get Task objects for scheduled celery tasks?

I am not sure you can actually get the actual Task instance, but you can easily create AsyncResult by simply instantiating it with the task ID you want to inspect, and you need (naturally) to pass the Celery application object to it too.

Some pseudo-code:

from celery.result import AsyncResult
from my.project.celeryapp import myapp

task_res = AsyncResult("9ed888fe-f6b6-4443-85d3-787c5c1b26b0", app=myapp)
print(task_res.state)


Related Topics



Leave a reply



Submit