Celery与RabbitMQ:AttributeError:'DisabledBackend'对象没有属性'_get_task_meta_for' - python

我正在运行First Steps with Celery Tutorial。

我们定义以下任务:

from celery import Celery

app = Celery('tasks', broker='amqp://guest@localhost//')

@app.task
def add(x, y):
    return x + y

然后调用它:

>>> from tasks import add
>>> add.delay(4, 4)

但是我收到以下错误:

AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'

我正在同时运行celery worker和Rabbit-mq服务器。奇怪的是,芹菜工人将任务报告为成功:

[2014-04-22 19:12:03,608: INFO/MainProcess] Task test_celery.add[168c7d96-e41a-41c9-80f5-50b24dcaff73] succeeded in 0.000435483998444s: 19 

为什么这不起作用?

参考方案

继续阅读教程。将在Keep Results章中进行解释。

要启动Celery,您只需要提供broker参数,这是发送有关任务的消息所必需的。如果要检索有关已完成任务返回的状态和结果的信息,则需要设置backend参数。您可以在Configuration docs: CELERY_RESULT_BACKEND中找到带有说明的完整列表。

单行的'if'/'for'语句是否使用Python样式好? - python

我经常在这里看到某人的代码,看起来像是“单线”,这是一条单行语句,以传统的“if”语句或“for”循环的标准方式执行。我在Google周围搜索,无法真正找到可以执行的搜索类型?任何人都可以提出建议并最好举一些例子吗?例如,我可以一行执行此操作吗?example = "example" if "exam" in exam…

在Django中,获取'str'对象没有属性'get' - python

views.pydef generate_xml(request, number): caller_id = 'x-x-x-x' resp = twilio.twiml.Response() with resp.dial(callerId=caller_id) as r: if number and re.search('[\d…

为什么使用'=='或'is'比较字符串有时会产生不同的结果? - python

我有一个Python程序,其中将两个变量设置为'public'值。在条件表达式中,我有比较var1 is var2失败,但如果将其更改为var1 == var2,它将返回True。现在,如果我打开Python解释器并进行相同的“是”比较,则此操作成功。>>> s1 = 'public' >>…

在返回'Response'(Python)中传递多个参数 - python

我在Angular工作,正在使用Http请求和响应。是否可以在“响应”中发送多个参数。角度文件:this.http.get("api/agent/applicationaware").subscribe((data:any)... python文件:def get(request): ... return Response(seriali…

Python:同时在for循环中添加到列表列表 - python

我想用for循环外的0索引值创建一个新列表,然后使用for循环添加到相同的列表。我的玩具示例是:import random data = ['t1', 't2', 't3'] masterlist = [['col1', 'animal1', 'an…