i trying create simple python pika selectconnection , seems not able open connection using on_open_callback , don't te on_open_error_callback either. can suggest might causing problem?
import pika class rabbitmqtransport(object): def __init__(self): self._connection = none self._channel = none self._connect() def on_connection_open(self): print "connection created" def on_connection_open_error(self): print "connection open error" def _connect(self): # setup rabbitmq connection credentials = pika.plaincredentials('guest','guest') parameters = pika.urlparameters('amqp://guest:guest@localhost:5672/%2f') print "creating connection" self._connection = pika.selectconnection(parameters=parameters,on_open_callback=self.on_connection_open,on_open_error_callback=self.on_connection_open_error) print self._connection.connection_state print dir(self._connection) print self._connection.is_open r = rabbitmqtransport()
found problem, added line bellow , connection opened , callback worked.
self._connection.ioloop.start()
Comments
Post a Comment