I submit 3 tasks which are chained together. Then I return the id of the chain with which later on I am trying to access the results
from celery.result import AsyncResult
from my_celery impor app
def get_results(task_id):
result = AsyncResult(task_id, app=app)
if result.ready():
return result.get()
return result.state
This AsyncResult is the result of the last task in chain. It also does not have its chain parents.
Is this a bug or I am doing somethign wrong?
Based on the answer here (it's likely an outdated method) - Get progress from async python celery chain by chain id, it mentions the following:
you can't recover the parent chain from just the task ID, you'd have to iterate over your queue which may or may not be possible depending on what you use as a broker.
In that case, you'd have to follow the method as suggested in that answer. But from also what I can see in the docs for AsyncResult()
, you should be able to pass the parent parameter as an argument and it should hold the parent value for a child. It's by default passed as None
, as can be seen from the method signature.
class celery.result.AsyncResult(id, backend=None, task_name=None, app=None, parent=None)