Here is the tasks.py
from celery.task import task
@task
def add(x, y):
return x + y
Here is the celeryconfig.py
print 'importing ' + __file__
BROKER_URL = "amqp://guest:guest@localhost:5672//"
CELERY_RESULT_BACKEND = "amqp"
CELERY_IMPORTS = ("tasks", )
Here is the file that i run. tasks.py:
from tasks import add
result = add.delay(4, 4)
print result.wait()
The program just stuck in the wait method.
Celeryd prints the following error:
Did you remember to import the module containing this task?
Or maybe you are using relative imports?
Please see http://bit.ly/gLye1c for more information.
The full contents of the message body was:
{'retries': 0, 'task': 'tasks.add', 'args': (4, 4), 'expires': None, 'eta': None
, 'kwargs': {}, 'id': '8c973638-4a87-4afa-8a78-958153066215'}
Traceback (most recent call last):
File "d:\python26\lib\site-packages\celery-2.4.5-py2.6.egg\celery\worker\consu
mer.py", line 427, in receive_message
eventer=self.event_dispatcher)
File "d:\python26\lib\site-packages\celery-2.4.5-py2.6.egg\celery\worker\job.p
y", line 297, in from_message
on_ack=on_ack, delivery_info=delivery_info, **kw)
File "d:\python26\lib\site-packages\celery-2.4.5-py2.6.egg\celery\worker\job.p
y", line 261, in __init__
self.task = registry.tasks[self.task_name]
File "d:\python26\lib\site-packages\celery-2.4.5-py2.6.egg\celery\registry.py"
, line 66, in __getitem__
raise self.NotRegistered(key)
NotRegistered: 'tasks.add'
When I run celeryd.py status, I the tasks.add is not here.
D:\Python26\Lib\site-packages\celery-2.4.5-py2.6.egg\celery\bin>celeryctl.py in
pect registered
<- registered
-> onfirenbpc: OK
* celery.backend_cleanup
* celery.chord
* celery.chord_unlock
* celery.ping
I run on windows, and linux as well. There are the same problem.
Does anyone know why?