芹菜和弦因valueerror的失败:没有足够的价值打开包装(预期2,得到1)
我正在运行 ubuntu 的 docker 容器中运行 celery v5.2.3。
在这里,我试图让芹菜和弦发挥作用,但我所做的每一次尝试都会给我带来:
File "/usr/local/lib/python3.7/site-packages/celery/result.py", line 1056, in result_from_tuple
res, nodes = r
ValueError: not enough values to unpack (expected 2, got 1)
出现此错误后,和弦会不断重试:
retry: Retry in 1.0s: ValueError('not enough values to unpack (expected 2, got 1)')
我尝试运行的任务如下:
@celery_app.task(shared=False)
def add(x, y):
return x + y
@celery_app.task(shared=False)
def tsum(numbers):
return numbers
@celery_app.task(name="celery.test")
def test():
x = chord([add.s(i, i) for i in range(10)], body=tsum.s())
r = x.apply_async()
r.get()
我的示例运行了 9/10 次迭代,但随后失败。
芹菜工人正在运行:
celery -A scheduler worker -P eventlet -l info
你们谁能告诉我我做错了什么,因为我在互联网上找不到任何解释这个问题的东西?
I am running celery v5.2.3 in a docker container running ubuntu.
Here I am trying to get celery chords to work but every attempt I make give me:
File "/usr/local/lib/python3.7/site-packages/celery/result.py", line 1056, in result_from_tuple
res, nodes = r
ValueError: not enough values to unpack (expected 2, got 1)
After this error the chord keeps retrying with:
retry: Retry in 1.0s: ValueError('not enough values to unpack (expected 2, got 1)')
The tasks I am trying to run is as follows:
@celery_app.task(shared=False)
def add(x, y):
return x + y
@celery_app.task(shared=False)
def tsum(numbers):
return numbers
@celery_app.task(name="celery.test")
def test():
x = chord([add.s(i, i) for i in range(10)], body=tsum.s())
r = x.apply_async()
r.get()
My sample runs for 9/10 iterations, but then fails.
The celery worker is running with:
celery -A scheduler worker -P eventlet -l info
Can any of you tell me what I am doing wrong as I cannot find anything on the internet explaining this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于未来任何不幸的人来说,都会遇到这个问题。
这个问题是因为我们为 celery 定制了 mongo 后端。
在这里,我们为任务定义了元字段,如下所示:
但是,由于 celery 期望孩子字段是孩子列表或无,我的问题是因为孩子字段总是由空列表填充。
通过将孩子改为:
问题就可以解决。
如果有人经历过这个,我希望这会有所帮助
For any unlucky soul in the future that should experience this issue.
The issue was cause with us having a custom implementation of the mongo backend for celery.
Here we defined the meta fields for the tasks as follows:
However as celery expects the children field to be a list of children or None, my issue was because the children field would always be populated by an empty list.
By changing children to:
The issue would be solved.
I hope this will help if anyone should experience this