TypeError: on_chord_error(( 缺少 2 个必需的位置参数:"exc"和"traceback"。
使用芹菜 4.3.0
阅读本文档 https://docs.celeryproject.org/en/latest/userguide/canvas.html#chords
chord_head_list = (add.s(i, i) for i in range(4))
res_chord = (group(chord_head_list) | callback.s().on_error(on_chord_error.s())).delay()
print(res_chord.get(timeout=20))
@app.task(name='tasks.callback')
def callback(result):
print('>>>>>>>>>>>>>>>>> callback {0}'.format(result))
return result
@app.task(name='tasks.on_chord_error')
def on_chord_error(request, exc, traceback):
print('>>>>>>>>>>>>>>>>> Task {0!r} raised error: {1!r}'.format(request.id, exc))
Celery 文档存在问题:https://github.com/celery/celery/issues/3709
您应该更改错误回调参数:
@app.task(bind=True, name='tasks.on_chord_error')
def on_chord_error(self, failed_task_id, param1, param2):
print(f"failed_task_id {failed_task_id}")
或:
@app.task(name='tasks.on_chord_error')
def on_chord_error(*args, **kwargs):
print(f"args={args}, kwargs={kwargs}")
我仍然缺少和弦组结果