我在我的系统中成功使用了和弦。但是,现在我有一个案例,我必须按顺序运行和弦数量(第二个在第一个结束时开始)。所以,我试图使用和弦链。但它对我不起作用。
@app.task(bind=True)
def some_celery_beat_worker(self):
feed_chain = []
for feed in feed_list:
celery_task_list = [perform single_task.si(url)
for url in some_url_list]
per_feed_chord = chord(celery_task_list, chord_callback.si(feed['_id'], feed['xml_file_name']))
feed_chain.append(per_feed_chord)
chain(*feed_chain).delay()
将此作为追溯:
Traceback (most recent call last): File "python3.4/site-packages/celery/app/trace.py", line 374, in trace_task R = retval = fun(*args, **kwargs) File "python3.4/site-packages/celery/app/trace.py", line 629, in __protected_call__ return self.run(*args, **kwargs) File "workers.py", line 156, in joblist_updater_worker chain(*feed_chain).delay() File "python3.4/site-packages/celery/canvas.py", line 182, in delay return self.apply_async(partial_args, partial_kwargs) File "/python3.4/site-packages/celery/canvas.py", line 566, in apply_async dict(self.options, **options) if options else self.options)) File "python3.4/site-packages/celery/canvas.py", line 596, in run first_task.apply_async(**options) File "python3.4/site-packages/celery/canvas.py", line 1241, in apply_async return (self.tasks[0] | body).set(task_id=task_id).apply_async( KeyError: 0
我需要的是修复这个特定的工作流程,或任何可以解决这个特殊问题的替代工作流程(一个接一个地运行和弦数量)
答案 0 :(得分:0)
问题在于我如何形成chain
。这不是正确的(至少对于我的芹菜版本),尽管在很多地方都有建议。
适用于我的方法。
feed_chain = chain()
for feed in feed_list:
feed_chain |= chord(args)
feed_chain.delay()