Celery ValueError: not enough values to unpack (expected 3, got 0)的解决方案

时间:2022-06-27 18:17:07

worker里报错:

[2018-01-12 19:08:15,545: INFO/MainProcess] Received task: tasks.add[5d387722-5389-441b-9b01-a619b93b4702]
[2018-01-12 19:08:15,550: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)',)
Traceback (most recent call last):
  File "d:\programmingsoftware\python35\lib\site-packages\billiard\pool.py", line 358, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
  File "d:\programmingsoftware\python35\lib\site-packages\celery\app\trace.py", line 525, in _fast_trace_task
    tasks, accept, hostname = _loc
ValueError: not enough values to unpack (expected 3, got 0)

解决:

原网页:Unable to run tasks under Windows

看别人描述大概就是说win10上运行celery4.x就会出现这个问题,解决办法如下,原理未知:

先安装一个`eventlet

pip install eventlet

然后启动worker的时候加一个参数,如下:

celery -A <mymodule> worker -l info -P eventlet

然后就可以正常的调用了。

运行

worker里输出:

[2018-01-12 19:35:33,640: INFO/MainProcess] Received task: tasks.add[3f9b5255-60a2-4a08-96b6-38f5fbc31543]
[2018-01-12 19:35:33,640: INFO/MainProcess] Task tasks.add[3f9b5255-60a2-4a08-96b6-38f5fbc31543] succeeded in 0.0s: 8