Reputation: 36404
These are my tasks:
@task(name = 'hello')
def hello():
print "hello"
return "helo"
@task(name = 'hey')
def hey(resp):
print resp
I'm calling them like this: g = celery.chain(hello.s(),hey.s())
But I want it to be done like this: hello task should return a value to not only to the task "hey" it should also a return a value back. By that I mean, I should be able to get the return value of "hello" once it is done executing. How to do it?
Upvotes: 1
Views: 1536
Reputation: 19479
The result instance returned when you call a chain will be for the last task in the chain, but it will keep a reference back to the parent, so you can traverse the parents to get the first task:
r = chain(hello.s(), hey.s())()
r.parent.get(timeout=1)
r.parent.parent.get(timeout=1)
first = r
while first.parent:
first = first.parent
See http://docs.celeryproject.org/en/latest/userguide/canvas.html#chains
Upvotes: 1