[rabbitmq-discuss] pika stops ioloop on disconnect

Marek Majkowski majek04 at gmail.com
Thu Jan 12 10:54:33 GMT 2012


On Wed, Jan 11, 2012 at 18:52, Enrico Zini <enrico at enricozini.org> wrote:
> 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:

I'm not sure how the tornado adapter works in Pika.
Please consider raising a bug if you think this behaviour
is a bug:
    https://github.com/pika/pika/issues

Also, it may help if you attached a runnable test case to the bug.

Cheers,
  Marek

>
>    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>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>


More information about the rabbitmq-discuss mailing list