运行环境
在Win10WSL子系统Ubuntu(20.04.2)下开发Django,使用Celery示例程序:
from celery import Celery
app = Celery('tasks',backend='redis://127.0.0.1',broker='redis://127.0.0.1')
@app.task
def app(x,y):
return x + y
报错
AttributeError: 'app' object has no attribute 'user_options'
解决方法
这里报错的原因是因为异步任务的命名和实例化Celery的名称冲突,导致歧义,这里把
def app(x,y)
中的换一个命名即可。