Celery Get List Of Registered Tasks

Richard Knop picture Richard Knop · Sep 26, 2014 · Viewed 27.1k times · Source

Is there a way to get a list of registered tasks?

I tried:

celery_app.tasks.keys()

Which only returns built in Celery tasks like celery.chord, celery.chain etc.

Answer

ChillarAnand picture ChillarAnand · Oct 6, 2014
from celery.task.control import  inspect
i = inspect()
i.registered_tasks()

This will give a dictionary of all workers & related registered tasks.

from itertools import chain
set(chain.from_iterable( i.registered_tasks().values() ))

In case if you have multiple workers running same tasks or if you just need a set of all registered tasks, it does the job.

Alternate Way:

From terminal you can get a dump of registered tasks by using this command

celery inspect registered

To inspect tasks related to a specific app, you can pass app name

celery -A app_name inspect registered