简体   繁体   English

芹菜链没有触发第二个任务

[英]celery chain is not triggering second task

I have two celery Tasks which should be run in strict order.我有两个芹菜任务,应该严格按照顺序运行。

def celery_run_tasks():
    chain(task_one.s(arg1, arg2), task_two.s(arg1, arg2)).apply_async()

So, first task taking 2 Arguments and in the end Populating some data to PostgreSQL table.因此,第一个任务采用2 Arguments ,最后将一些数据填充到 PostgreSQL 表中。 After that second task should Start, get data from FIRST table , generate new calculations and post them to SECOND PostgreSQL table.在第二个任务应该开始之后,从FIRST table获取数据,生成新的计算并将它们发布到SECOND PostgreSQL 表中。

The problem what I see with my code that its populating all data to first table, but second one is empty.我在代码中看到的问题是将所有数据填充到第一个表中,但第二个表是空的。 I tried different variations with Chord and Groups and its still does not work.我尝试了 Chord 和 Groups 的不同变化,但它仍然不起作用。

Let me know what you think and Please be specific.让我知道您的想法,请具体说明。 Thank you.谢谢你。

PS I did check Celery documentation!, please don't just post link to it. PS 我确实检查了 Celery 文档!请不要只发布它的链接。

So issue was that first task was sending result of it to second task as first argument.所以问题是第一个任务将它的结果作为第一个参数发送到第二个任务。 So my second task receive 3 arguments instead of two and give error.所以我的第二个任务收到 3 个参数而不是两个并给出错误。 To avoid it make second task as si which mean not accept any arguments from previous tasks and it will work:为避免将第二个任务设为si ,这意味着不接受来自先前任务的任何参数,它将起作用:

def celery_run_tasks():
    chain(task_one(arg1, arg2), task_two.si(arg1, arg2)).apply_async()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM