我无法让芹菜运行,不确定我做错了什么。我安装了Celery和RabbitMQ库。我的rabbitmq在5672端口上运行。我对它的定义如下
from celery import Celery
app = Celery('tasks', backend='rpc://', broker='amqp://guest:guest@localhost:5672//')
@app.task(ignore_result=True)
def add(x, y):
return x + y然后,我使用下面的命令运行我的worker
celery -A tasks worker --loglevel=info但是当我执行下面的操作时,我得到了错误消息。这是一个简单的基本示例,它应该运行没有任何问题,但仍然不能让它运行。
Python 2.7.10 (default, Oct 23 2015, 17:36:57)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tasks import add
>>> result = add.delay(4, 4)
>>> result.ready()
False
>>> result.get(timeout=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/pythonbrew/pythons/Python-2.7.10/lib/python2.7/site-packages/celery/result.py", line 16 9, in get
no_ack=no_ack,
File "/usr/local/pythonbrew/pythons/Python-2.7.10/lib/python2.7/site-packages/celery/backends/amqp.py", line 157, in wait_for
raise TimeoutError('The operation timed out.')
celery.exceptions.TimeoutError: The operation timed out.发布于 2015-12-13 13:23:13
尝试使用app.backend.get_result(result.id)
https://stackoverflow.com/questions/34221093
复制相似问题