芹菜:为什么可能导致'结果'属性丢失了?

时间:2016-12-23 19:02:11

标签: python python-2.7 celery

我已经输入了一行代码,如下所示:

some_var = celery.result.AsyncResult(id)
此示例中的

celery 是从celery模块导入的Celery类的实例,这是控制台中发生的情况:

AttributeError: 'Celery' object has no attribute 'result'

另外请注意,如果我在上面的代码行中将 celery 更改为不是Celery类的实例,而是:

import celery

芹菜模块本身,然后发生此错误:

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

这可能会发生什么?

1 个答案:

答案 0 :(得分:0)

AsyncResultcelery.result模块中的一个类。

result应用程序对象上没有Celery属性。

只要在从Celery包导入后对其进行初始化,就可以调用celery实例celery

# here "celery" refers to the celery package
from celery.result import AsyncResult 

# ... doesn't matter what "celery" points to here ...

result = AsyncResult("task-id")