python - celery task decorator throws "TypeError: 'Module object is not callable" -


i'm trying desperately celery play nicely django, no avail. getting tripped on following:

project/settings.py:

...  import djcelery djcelery.setup_loader()  broker_url = 'django://' celery_result_backend = 'django://' celery_task_serializer = 'json' celery_result_serializer = 'json' celery_enable_utc = true  ... 

app/tasks.py:

from celery.task import task  @task() def scheduled_task(param1, param2):     ...     return 

calling scheduled_task(param1, param2) directly (without decorator) works expected. when adding decorator , firing 'development' celery worker so:

python manage.py celery worker --loglevel=info 

...i following error:

typeerror: 'module' object not callable 

i've pinned down @task decorator. every combination try fails, including:

from celery import task celery.task import task celery.task.base import task  @task @task() @task.task @task.task() @celery.task @celery.task() 

nothing seems make difference call stack in exception, appear think task module, , not callable! make things more frustrating:

>>> celery.task import task >>> task <function task @ 0x10aa2a758> 

that sure looks callable me! idea might happening? if i've missed anything, i'm happy post additional logs, files or clarify else.

(converted answer comments)

from stack trace take line return backend(app=self, url=url) exception happens.

so whatever backend is, doesn't seem callable. try set pdb breakpoint in file (celery/app/base.py) wrapping line in

try:     backend(app=self, url=url) except:     import pdb; pdb.set_trace(), 

and inspecting backend, , moving stack (u command in pdb, d go down again, w display call stack) debug goes wrong.

the celery docs mention this:

how import task decorator?

the task decorator available on celery instance, if don’t know please read first steps celery.

if you’re using django or still using “old” module based celery api, can import task decorator this:

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

so should clear amiguity way import task decorator right one.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -