Django プロジェクトでセロリをセットアップしましたが、タスクを正しく実行できないようです。Ubuntu 13.04でDjango 1.4.3、セロリ3.0.1、django-celery 3.0.17、およびPython 2.7を使用しています。
rabbitmq-server が実行されていることを確認しました。
sudo service rabbitmq-server status
Status of node rabbit@fenster ...
[{pid,1667},
{running_applications,[{rabbit,"RabbitMQ","3.0.2"},
{os_mon,"CPO CXC 138 46","2.2.9"},
{mnesia,"MNESIA CXC 138 12","4.7"},
{sasl,"SASL CXC 138 11","2.2.1"},
{stdlib,"ERTS CXC 138 10","1.18.1"},
{kernel,"ERTS CXC 138 10","2.15.1"}]},
{os,{unix,linux}},
{erlang_version,"Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:30] [kernel-poll:true]\n"},
{memory,[{total,28112760},
{connection_procs,93432},
{queue_procs,42680},
{plugins,0},
{other_proc,9331824},
{mnesia,65288},
{mgmt_db,0},
{msg_index,86656},
{other_ets,764048},
{binary,1343288},
{code,12372068},
{atom,512601},
{other_system,3500875}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,6719406080},
{disk_free_limit,1000000000},
{disk_free,122925531136},
{file_descriptors,[{total_limit,924},
{total_used,7},
{sockets_limit,829},
{sockets_used,3}]},
{processes,[{limit,1048576},{used,151}]},
{run_queue,0},
{uptime,275789}]
...done.
virtualenv で Django プロジェクトをセットアップしています。settings.py ファイルでセロリを次のように構成しました。
INSTALLED_APPS = [
# django apps
# our apps ...
# third party modules ...
'djcelery',
]
import djcelery
djcelery.setup_loader()
CELERY_IMPORTS = ('my.task')
RabbitMQ ブローカーは適切にセットアップされています。他のセロリ タスクが適切に実行されています。
私の仕事:
import celery
class MyClass(object):
@celery.task()
def my_task(self, new, old):
# do stuff
return
def kick_off_tasks(self):
# do stuff
new = 'something'
old = 'something else'
self.my_task.apply_async(args(new, old), kwarg1='new', kwarg2='old)
# do more stuff
呼び出すビューを実行するとkick_off_tasks
、celeryd 情報ログに次のメッセージが表示されます。
./manage.py celeryd --loglevel=info
[Tasks]
. my.task
. other.tasks
. more.tasks
. etc.etc.etc
[2013-08-23 14:18:40,772: WARNING/MainProcess] celery@fenster has started.
[2013-08-23 14:20:40,757: ERROR/MainProcess] Received unregistered task of type 'my.task'.
The message has been ignored and discarded.
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': 'my.task', 'eta': None, 'args': ('something, 'something else'), 'expires': None, 'callbacks': None, 'errbacks': None, 'kwargs': {}, 'id': 'bf4d5ee7-9701-42b6-a887-c6b6470d9810', 'utc': True} (2297b)
Traceback (most recent call last):
File "/home/ricomoss/.virtualenvs/proton/local/lib/python2.7/site-packages/celery/worker/consumer.py", line 394, in on_task_received
strategies[name](message, body, message.ack_log_error)
KeyError: 'my.task'
助言がありますか?