问题
I have two queues in Celery and one tasks.py with tasks. When I run celery with
celery worker -A myapp -l info -Q messages1
celery worker -A myapp -l info -Q messages2
in two different terminals, it works fine and run all my tasks.
But if I run in with
celery multi start 2 -Q:1 messages1 -Q:2 messages2 --loglevel=DEBUG
I get [2014-05-08 15:30:33,020: ERROR/MainProcess] Received unregistered task of type
.
What I`m doing wrong?
UPDATE: I've found, that
celery worker -A myapp -l info -Q messages1
celery worker -A myapp -l info -Q messages2
actualy runs one worker. When I specify -n param to each worker:
celery worker -A myapp -l info -Q messages1 -n w1
celery worker -A myapp -l info -Q messages2 -n w2
I have the same problem:
[2014-05-08 16:51:05,329: ERROR/MainProcess] Received unregistered task of type
Update 1: I've already have the following line:
CELERY_ROUTES = {'messages.tasks.send_message': {'queue': 'message_send'}, 'messages.tasks.control_message_send': {'queue': 'message_manager'}}.
Seems there is no effect. And I run task like this:
result = send_message.apply_async(('number', 'message text'), queue='message_send').
回答1:
The problem was solved with two steps:
1) Correct run string for celery multi was celery multi start 2 -Q:1 messages1 -Q:2 messages2 --loglevel=DEBUG -A myapp
2) I forgot to import my app in the __init__.py
:
`from __future__ import absolute_import
from myapp.celery_app import celery_app as celery_app`
And this link from the log message is realy useful. http://docs.celeryq.org/en/latest/userguide/tasks.html#task-names
来源:https://stackoverflow.com/questions/23534867/python-celery-multi-unregistred-task