[rabbitmq-discuss] pika stops ioloop on disconnect
Enrico Zini
enrico at enricozini.org
Wed Jan 11 18:52:19 GMT 2012
Hello,
I'm trying to deal with RabbitMQ outages from a tornado-based pika
sender. Currently on pika 0.9.5 (the latest stable release afaict).
If I stop RabbitMQ, I correctly get my on_close_callback notified.
However, pika also stops the Tornado IOLoop with this code in
base_connection.py:
def _adapter_disconnect(self):
"""
Called if we are forced to disconnect for some reason from Connection
"""
# Remove from the IOLoop
self.ioloop.stop()
# Close our socket
self.socket.close()
def _handle_disconnect(self):
"""
Called internally when we know our socket is disconnected already
"""
# Remove from the IOLoop
self.ioloop.stop()
# Close up our Connection state
self._on_connection_closed(None, True)
self.ioloop.stop() doesn't remove anything from the tornadio ioloop, but
just stops it. That's a rather surprising behaviour to me.
I can of course wrap the ioloop.start() call in my application inside a
"while True:", but before I pick up the axe I'd like to understand what
is going on: is the Tornado IOLoop stopped for a reason?
Note that _adapter_disconnect in TornadoConnection seems to do the right
thing:
def _adapter_disconnect(self):
"""
Disconnect from the RabbitMQ Broker
"""
# Remove from the IOLoop
self.ioloop.remove_handler(self.socket.fileno())
# Close our socket since the Connection class told us to do so
self.socket.close()
# Let the developer know to look for this circumstance
warn("Tornado IOLoop may be running but Pika has shutdown.")
but _handle_disconnect is not overridden in TornadoConnection, so
ioloop.stop() is still called.
Looks like a bug to me, but I'd like to double check it here since I've
only just started looking into pika's code.
Ciao,
Enrico
--
GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini <enrico at enricozini.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120111/4509eed6/attachment.pgp>
More information about the rabbitmq-discuss
mailing list