From acefc0fb42c99dc73c624ffc3601e3ad96d67ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Fierek?= Date: Tue, 12 Oct 2021 14:43:08 +0200 Subject: [PATCH] fix problem with dangling channels on connection restore This patch fixes problem with unexpected restoration already closed channels (after reconnect to the AMQP broker) when the `RobustConnection` is being used. The problem is caused by the not freeing reference to the `aiopika.Channel._on_return` kept by the `aiormq.Channel.on_return_callbacks`, which blocks garbage collector against free a `RobustChannel` object. --- aio_pika/channel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aio_pika/channel.py b/aio_pika/channel.py index 25bab2af..888c905b 100644 --- a/aio_pika/channel.py +++ b/aio_pika/channel.py @@ -93,6 +93,7 @@ async def close(self, exc=None): # noinspection PyTypeChecker channel = self._channel # type: aiormq.Channel + channel.on_return_callbacks.remove(self._on_return) self._channel = () await channel.close()