在为 django 试用 celery 时,我遇到了 @task 装饰器的问题。这是在 Windows 7 上运行的。
在我的 celerytest.tasks 模块中,我有以下代码
from celery import task
@task
def add(x,y):
return x + y
从命令提示符我运行:
python manage.py shell
尝试从 shell 导入我的模块:
from celerytest.tasks import add
我收到以下错误:
>>> from celerytest.tasks import add
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "d:\...\celerytest\tasks.py", line 8, in <module>
@task
TypeError: 'module' object is not callable
我试着用谷歌搜索了很长时间,但似乎我是世界上唯一一个遇到这个问题的人。