py芹多次未登记任务 [英] python celery multi unregistred task

查看:91
本文介绍了py芹多次未登记任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Celery中有两个队列,一个tasks.py的任务。
当我运行芹菜与

 芹菜工作者-A myapp -l info -Q messages1 
芹菜工作者 - 在两个不同的终端中,myapp -l info -Q messages2

它可以正常运行,任务。



但是,如果我使用

 芹菜多重启动2 -Q:1个消息1 -Q:2个消息2 --loglevel = DEBUG 

我得到 [2014-05-08 15:30:33,020:ERROR / MainProcess]收到类型为的未注册任务。
我做错了什么?



更新:我发现,

 芹菜工作者-A myapp -l info -Q messages1 
芹菜工作者-A myapp -l info -Q messages2

实际运行一个工作人员。当我为每个工作者指定-n参数时:

 芹菜工作者-A myapp -l info -Q messages1 -n w1 
芹菜工人-A myapp -l info -Q messages2 -n w2

我有同样的问题:

  [2014-05-08 16:51:05,329:错误/ MainProcess]收到未注册的任务类型

更新1:
我已经有以下行: p>

  CELERY_ROUTES = {'messages.tasks.send_message':{'queue':'message_send'},'messages.tasks.control_message_send' :{'queue':'message_manager'}}。 

似乎没有任何效果。我运行这样的任务:

  result = send_message.apply_async(('number','message text'), 'message_send')。 


解决方案

问题解决了两个步骤:



1)芹菜多的正确运行字符串为芹菜多重启动2 -Q:1个消息1 -Q:2个消息2 --loglevel = DEBUG -A myapp



2)我忘记在 __ init __。py 中导入我的应用程序: p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $从$ _ >

从日志消息的这个链接是非常有用的。 http://docs.celeryq.org/en/latest/userguide /tasks.html#task-names


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'). 

解决方案

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

这篇关于py芹多次未登记任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆