AsyncResult Celery Gets Host Name

I have a celery that uses two different servers to handle tasks. I am trying to find a better way to map the server on which this task is performed. I looked through the docs and saw nothing about getting the hostname from AsyncResult.

Any input on this subject is welcome. Another option that I was thinking about is to simply put the hostname in each celery configuration, although this method is not needed as this is another thing to keep in mind.

+8
celery django-celery
source share
1 answer

A possible workaround is to return the host name with the return value of the task

from celery import current_task @celery.task def hello(x, y): return dict(hostname=current_task.request.hostname, result='hello') 
+5
source share

All Articles