Search code examples
celerycelery-task

Celery task display name


I have some Celery tasks and I'm checking their states periodically from a separate process by instantiating an AsyncResult using the task id.

From this, I get the task state. By implementing a custom results backend and extended AsyncResult class as described here, I'm able to also get the task name too. However, I want able to get a custom display name for each task - something human readable so that I can display the state info in a user friendly way.

Hypothetically, it might be set something like:

@app.task()
def my_task(args):
    display_name = "My Task"
    ...
    ...

Then later I would do...

result = ExtendedAsyncResult(task_id)
result.display_name

But from looking at the custom results backend I linked to, there doesn't appear to be any way to access the local variables of the task.

Is there a way to achieve what I'm looking for?


Solution

  • Celery support task name - hope this is what you are looking for:

    @app.task(name='My Task')
    def my_task(args):
        ...
        ...
    

    the My Task will now appear wherever you want (in flower for example).