尝试用芹菜运行简单的示例并接收异常。RabbitMQ在Docker中启动,也尝试在本地启动。芹菜在本地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,628: INFO/MainProcess] Received task: tasks.hello[8d33dbea-c5d9-4938-ab1d-0646eb1a3858] [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)
对于Windows上的
Celery 4.1
。设置环境变量
FORKED_BY_MULTIPROCESSING=1
。然后您可以简单地运行celery -A <celery module> worker
。哪个芹菜版本?据我所知,从芹菜4开始,windows就不支持芹菜了
Celery 4.0+
尚未正式支持Windows。但出于某些开发/测试目的,它仍然可以在Windows上运行。使用
eventlet
代替如下:它在
Windows 10
+celery 4.1
+python 3
上对我有效。===更新2018-11==
Eventlet在子进程上有问题。调用的进程错误:
https://github.com/celery/celery/issues/4063
https://github.com/eventlet/eventlet/issues/357
https://github.com/eventlet/eventlet/issues/413
所以试着
gevent
代替。这在
Windows 10
+celery 4.2
+python 3.6
上对我有效相关问题 更多 >
编程相关推荐