Git Product home page Git Product logo

Comments (2)

mosquito avatar mosquito commented on July 17, 2024

It's not a typo. The aio_pika.Channel uses the pika.Channel through pika.Connection instance. When connection closes the pika.Connection instance is not created yet and this exception raises.

This behaviour explicit. What behaviour will be fine for you?

from aio-pika.

fortiema avatar fortiema commented on July 17, 2024

Thanks. Not sure I fully understand though - I was under the impression that the error gets thrown at re-connection, where RobustChannel tries to re-init itself. It means that the connection object passed to on_reconnect() has not been instantiated, correct?

def on_reconnect(self, connection, channel_number):
        exc = ConnectionError('Auto Reconnect Error')

        if not self._closing.done():
            self._closing.set_exception(exc)

        self._closing = create_future(loop=self.loop)
        self._futures.reject_all(exc)
        self._connection = connection
        self._channel_number = channel_number

        yield from self.initialize()

        for name, exchange in self._exchanges.items():
            yield from exchange.on_reconnect(self)

        for name, queue in self._queues.items():
            yield from queue.on_reconnect(self)

In that case, would it be better to add a check (or await?) on the connection before trying to recreate a channel?

Just to give you some context: I am trying to write an always-running producer that needs to be robust to the fact that (1) rabbitmq might not be available at startup or (2) rabbitmq might become unavailable at any point after startup. I seem to have issues getting it to work as intended (for example, it will reconnect once rabbitmq recovers, but the task won't move on with what it should do).

from aio-pika.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.