【发布时间】:2012-11-11 03:52:58
【问题描述】:
类似的问题似乎都基于使用自定义记录器,我很高兴只使用默认/无。我的 pika python 应用程序运行并接收消息,但几秒钟后与No handlers could be found for logger "pika.adapters.blocking_connection" 崩溃,有什么想法吗?
import pika
credentials = pika.PlainCredentials('xxx_apphb.com', 'xxx')
parameters = pika.ConnectionParameters('bunny.cloudamqp.com', 5672, 'xxx_apphb.com', credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare('messages')
def message_received(channel, method, properties, body):
print "[x] Received %r" % (body)
channel.basic_consume(message_received, queue='messages', no_ack=True)
channel.start_consuming()
通过添加修复:
import logging
logging.basicConfig()
【问题讨论】:
-
当我从 CentOS 5 升级到 CentOS 6 时遇到了类似的问题,我的问题是我的 rabbit 服务被终止了。在那只兔子没有死之后,我不得不从 inittab 更改为 initctl 来启动我的 python 脚本。想我会分享我的评论,以防它帮助任何人。