Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No handlers could be found for logger "pika.adapters.blocking_connection"

Tags:

python

amqp

pika

Similar questions all seem to be based around using a custom logger, I'm happy to just use the default / none at all. My pika python app runs and receives messages but after a few seconds crashes with No handlers could be found for logger "pika.adapters.blocking_connection", any ideas?

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()

Fixed by adding:

import logging
logging.basicConfig()
like image 816
Mim Hufford Avatar asked Nov 22 '12 17:11

Mim Hufford


2 Answers

Fixed by adding:

import logging
logging.basicConfig()
like image 96
Mim Hufford Avatar answered Oct 23 '22 21:10

Mim Hufford


There should be exchange name provide, it should not left default.

channel.exchange_declare(exchange='anyname')  
like image 29
user1733908 Avatar answered Oct 23 '22 22:10

user1733908