mbstacy
mbstacy

Reputation: 13

Celery inspect worker tasks and retrieve the task docstrings

I'm working with a celery worker node and developing a Django Rest API to handle celery task submission. I can get a list of tasks through inspect()

     i = app.control.inspect()
     i.registerd()

But need to get the docstring from worker node tasks. This will be used for the GET request to display useful helpful information to end user. The Celery task code is not install within the django rest api application. So how to inspect tasks on worker and return the docstring for task. Any help would be greatly appreciated.

Upvotes: 1

Views: 713

Answers (1)

Jacky Wang
Jacky Wang

Reputation: 3490

The prototype of registered is

def registered(self, *taskinfoitems): 
    return self._request('dump_tasks', taskinfoitems=taskinfoitems) 

You could specify __doc__ in the taskinfoitems parameter

Upvotes: 1

Related Questions