ValueError: not enough values to unpack (expected 3, got 0)问题
检查自己的电脑上是否有eventlet库
安装
pip install eventlet
然后启动worker的时候加一个参数,如下:(执行任务)
celery worker -A celery_tasks -l INFO
- 将上面命令改为下面命令就好啦!
celery -A celery_tasks worker -l info -P eventlet
完整代码如下:
项目目录:
celery.py
from __future__ import absolute_import, unicode_literals
from celery import Celery
app = Celery("celery_tasks", broker='redis://127.0.0.1/0', backend='redis://127.0.0.1/1', include=[
'celery_tasks.tasks',
])
app.conf.update(
result_expires=3600,
)
if __name__ == '__main__':
app.start()
tasks.py
from __future__ import absolute_import, unicode_literals
from celery_tasks.celery import app
@app.task
def add(x, y):
return x + y
@app.task
def mul(x, y):
return x * y
@app.task
def xsum(numbers):
return sum(numbers)
执行一下命令: