I have 3 employees and I am trying to create multiple celery tasks like this:
我有3名员工,我正在尝试创建这样的多个芹菜任务:
for e in employees:
res1 = escalate.apply_async((e.id), countdown=3)
print res1.id
This should create 3 tasks but it only creates 1.
这应该创建3个任务,但它只创建1个。
Each id prints out: dc553662-283e-46e5-b811-7c1f5ed08d2d be7043bc-02a1-4641-b8e6-c230bf1d7325 5b88e6cc-8514-4e80-8f4f-eb8b05f3625b
每个id打印出来:dc553662-283e-46e5-b811-7c1f5ed08d2d be7043bc-02a1-4641-b8e6-c230bf1d7325 5b88e6cc-8514-4e80-8f4f-eb8b05f3625b
Is there a limitation in celery that doens't allow me to create multiple tasks in this way? If not, how can I create multiple tasks in a loop?
芹菜是否有限制,不允许我以这种方式创建多个任务?如果没有,我如何在循环中创建多个任务?
1 个解决方案
#1
0
You can pass those employee ids as a list to the task, iterate over it in "escalate" task and do whatever functionality you intend to. That's how I would have gone with this.
您可以将这些员工ID作为列表传递给任务,在“升级”任务中迭代它并执行您想要的任何功能。这就是我对此的看法。
#1
0
You can pass those employee ids as a list to the task, iterate over it in "escalate" task and do whatever functionality you intend to. That's how I would have gone with this.
您可以将这些员工ID作为列表传递给任务,在“升级”任务中迭代它并执行您想要的任何功能。这就是我对此的看法。