我的芹菜架上有多个任务,所有任务都链接在一起。像这样:
for i in n:
a = a.si()
....
mychain = chain(a, b, c, d)
mychain.apply_async()
您可以看到它们运行了n次,创建了n个链。我的问题是我可以再执行一个任务“ e”(有点像清理任务-文件,数据库等),该任务将在“ n”个链完成执行后运行吗? 最后,我可以在最终的迭代链中很好地做到这一点,但是还有更好的方法吗?
答案 0 :(得分:1)
您需要为此使用和弦
https://docs.celeryproject.org/en/latest/userguide/canvas.html
A chord is just like a group but with a callback. A chord consists of a
header group and a body, where the body is a task that should execute after
all of the tasks in the header are complete.