芹菜链没有触发第二任务

发布于 2025-02-04 10:15:43 字数 406 浏览 3 评论 0原文

我有两个芹菜任务,应严格运行。

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

因此,第一个任务进行2参数,最后将一些数据填充到PostgreSQL表中。 第二个任务应启动之后,从第一个表中获取数据,生成新计算,然后将其发布到第二个 postgresql表。

我在代码中看到的问题是,它将所有数据填充到第一个表格,但第二个是空的。我尝试了和弦和小组的不同变化,但它仍然不起作用。

让我知道您的想法,请具体说明。谢谢。

PS我确实检查了芹菜文档!,请不要仅仅发布链接。

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.
After that second task should Start, get data from FIRST table, generate new calculations and post them to SECOND PostgreSQL table.

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.

Let me know what you think and Please be specific. Thank you.

P.S. I did check Celery documentation!, please don't just post link to it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤单情人 2025-02-11 10:15:43

因此问题是,第一个任务是将其结果发送到第二个任务作为第一个参数。因此,我的第二任任务收到3个参数,而不是两个参数并给出错误。
为了避免将第二个任务作为si,这意味着不接受以前任务的任何参数,它将有效:

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

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.
To avoid it make second task as si which mean not accept any arguments from previous tasks and it will work:

def celery_run_tasks():
    chain(task_one(arg1, arg2), task_two.si(arg1, arg2)).apply_async()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文