From 63db1845582ce95dfbd3b3a9180f3f28d0ae6c23 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Tue, 23 Jan 2024 02:42:19 -0500 Subject: [PATCH] fix: If the client attempts to close the connection while it is opening, do not retry opening the connection. --- docs/changelog.rst | 5 +++++ yapw/clients.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index cb84f27..ea9be46 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,11 @@ Changed - Remove log message for declaring exchange. - Remove ``yapw.clients.Base.__getsafe__``. +Fixed +~~~~~ + +- If the client attempts to close the connection while it is opening, do not retry opening the connection. + 0.1.3 (2023-07-03) ------------------ diff --git a/yapw/clients.py b/yapw/clients.py index 843cdf0..93f4371 100644 --- a/yapw/clients.py +++ b/yapw/clients.py @@ -18,7 +18,7 @@ import pika from pika.adapters.asyncio_connection import AsyncioConnection -from pika.exceptions import ProbableAccessDeniedError, ProbableAuthenticationError +from pika.exceptions import ConnectionOpenAborted, ProbableAccessDeniedError, ProbableAuthenticationError from pika.exchange_type import ExchangeType from yapw.decorators import halt @@ -438,7 +438,7 @@ def reset(self) -> None: def connection_open_error_callback(self, connection: pika.connection.Connection, error: Exception | str) -> None: """Retry, once the connection couldn't be established.""" - if isinstance(error, ProbableAccessDeniedError | ProbableAuthenticationError): + if isinstance(error, ConnectionOpenAborted | ProbableAccessDeniedError | ProbableAuthenticationError): logger.error("Stopping: %r", error) self.connection.ioloop.stop() else: