mosquito / aio-pika

AMQP 0.9 client designed for asyncio and humans.
https://aio-pika.readthedocs.org/
Apache License 2.0
1.23k stars 187 forks source link

Channel.reopen should optionally pass a timeout value to the initialize call #448

Open selimt opened 2 years ago

selimt commented 2 years ago

Currently Channel.reopen is calling initialize with no arguments so the timeout value ends up being None.

In some cases we use a "non restoring channel" so that if the broker stops working we can detect it on the client side and stop trying to send messages after retrying a few times. The proposed fix is as follows:

In https://github.com/mosquito/aio-pika/blob/master/aio_pika/channel.py#L244 :

    async def reopen(self, timeout: TimeoutType = None) -> None:
        if hasattr(self, "_channel"):
            del self._channel

        self._is_closed_by_user = False
        await self.initialize(timeout=timeout)