python - celery 引发 ValueError : not enough values to unpack

标签 python celery

尝试使用 Celery 运行简单示例并收到异常。 RabbitMQ 在 Docker 中启动,也尝试在本地启动它。 Celery 在本地 Windows 主机上运行

from celery import Celery

app = Celery('tasks', broker='amqp://192.168.99.100:32774')

@app.task()
def hello():
    print('hello')


if __name__ == '__main__':
    hello.delay()

我的错误文本摘录:

[2017-08-18 00:01:08,632: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)',)
Traceback (most recent call last):                                              
    File "c:\users\user\celenv\lib\site-packages\billiard\pool.py", line 358, in workloop                        
        result = (True, prepare_result(fun(*args, **kwargs)))                                  
    File "c:\users\user\celenv\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)

最佳答案

Celery 4.0+ 还没有正式支持 Windows。但出于某些开发/测试目的,它仍然可以在 Windows 上运行。

使用 eventlet 代替如下:

pip install eventlet
celery -A <module> worker -l info -P eventlet

它适用于 Windows 10 + celery 4.1 + python 3

===== 2018-11 更新 =====

Eventlet 在 subprocess.CalledProcessError 上有问题:

https://github.com/celery/celery/issues/4063

https://github.com/eventlet/eventlet/issues/357

https://github.com/eventlet/eventlet/issues/413

所以试试 gevent 吧。

pip install gevent
celery -A <module> worker -l info -P gevent

这适用于 Windows 10 + celery 4.2 + python 3.6

关于python - celery 引发 ValueError : not enough values to unpack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45744992/

相关文章:

python - 使用 docker 时运行 postgres 容器

python - Ceph radosgw - 存储桶策略 - 默认使所有对象公开读取

django - Celery + Django 信号

python - 强制 Celery 使用 Python 3

python - 继承 celery 任务

python - 具有 Null 值的平均数组

python - Matplotlib 热图,垂直底部标签

python - 如何判断 VS Code 使用的 Python 格式化程序的版本?

django - Postgres : prioritize main application over background celery jobs

python - Celery 4.1 周期性任务错误