初学,按 blog 写最简单的代码:tasks.py
from celery import Celery
app = Celery('tasks', broker='redis://127.0.0.1:6379', backend='redis://127.0.0.1:6379/0')
@app.task
def add(x, y):
return x + y
启动 celery,一切正常 在同 task.py 目录下进入 python 终端
>>> from tasks import add
>>> result = add.delay(1,2)
>>> result.ready()
总是返回 False(试过 n 遍),当在启动 celery 端已显示成功,请问这是为什么? (celery==3.1.8 redis==3.2)
1
MarcoQin 2017-08-15 18:38:08 +08:00 1
刚查了下官方文档,这样写
AsyncResult.ready()[source] Return True if the task has executed. If the task is still running, pending, or is waiting for retry then False is returned. |
2
Zioyi OP 问题解决,celery -A tasks worker --loglevel=info --pool=solo (添加参数 --pool=solo )
https://cn.v2ex.com/t/177589 |
3
eloah 2017-08-15 20:25:15 +08:00
4 已经不支持 windows 了......
|