【发布时间】:2012-06-02 17:26:39
【问题描述】:
为 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
我用谷歌搜索了很长时间,但似乎我是世界上唯一遇到这个问题的人。
【问题讨论】: