Sometimes I need to run task B after task A, but return the result of task A. Looking at the docs, I have tried to ( Avoid launching synchronous subtasks )
So I would use a chain, like this:
@celery.task
def A():
return 5
@celery.task
def B():
return 2
def do_all():
chain = A.s() | B.s()
chain()
return result_of_A
But this would not work. In my case I need:
Is it possible to implement this with chains or any other subtasks primitives?
I can't noodle a way to do this with primitives; there probably is one. But a different approach that would work is, use the on_success
or after_return
handler in task A to initiate task B. If you also use the ignore_result
option, then the invocation of task B would be truly fire-and-forget.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.