我已经输入了一行代码,如下所示:
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'
这可能会发生什么?
答案 0 :(得分:0)
AsyncResult
是celery.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")