Getting TypeError: 'Module' object is not callable on celery task decorator

☆樱花仙子☆ 提交于 2019-12-10 03:48:57

问题


Trying out celery for django I ran into a problem with @task decorator. This is running on Windows 7.

In my celerytest.tasks module I have the following code

from celery import task

@task
def add(x,y):
    return x + y

From the command prompt I run:

python manage.py shell

Trying to import my module from shell:

from celerytest.tasks import add

I get the following error:

>>> 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

I tried googling this for a long time, but it seems I am the only one in the world with this problem.


回答1:


Well, I was reading the documentation for 2.6.0 rc3, but installed 2.5.3.

http://ask.github.com/celery/django/first-steps-with-django.html

When using the import like this:

from celery.task import task

everything seems to work.



来源:https://stackoverflow.com/questions/10864436/getting-typeerror-module-object-is-not-callable-on-celery-task-decorator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!