From cf10462ade5a3336bf913e558086c6c929e19989 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 17 Oct 2023 00:52:27 +0200 Subject: [PATCH] Fix possible error iterating on connection channels during concurrent update Fix for the crash reported in #589 unfortunately not tested to verify if the fix is complete. --- aio_pika/robust_connection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aio_pika/robust_connection.py b/aio_pika/robust_connection.py index 254e089e..c1a28368 100644 --- a/aio_pika/robust_connection.py +++ b/aio_pika/robust_connection.py @@ -95,7 +95,9 @@ async def _on_connected(self) -> None: raise RuntimeError("No active transport for connection %r", self) try: - for channel in self.__channels: + # Make a copy of the channels to iterate on, to guard from + # concurrent updates to the set. + for channel in tuple(self.__channels): try: await channel.restore() except Exception: