From 874c440f9ba3b227193630e35cff00771b5164df Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sun, 30 Nov 2025 20:55:25 +0000 Subject: [PATCH] Use `MaxConnectionsError` in the asyncio pool too This aligns to the docs which indicate that this error type will be used when pool attempts to create more connections than are allowed. Fixes https://github.com/redis/redis-py/issues/3237 --- redis/asyncio/connection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index b819836af6..c5764f7343 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -57,6 +57,7 @@ AuthenticationWrongNumberOfArgsError, ConnectionError, DataError, + MaxConnectionsError, RedisError, ResponseError, TimeoutError, @@ -1208,7 +1209,7 @@ def get_available_connection(self): connection = self._available_connections.pop() except IndexError: if len(self._in_use_connections) >= self.max_connections: - raise ConnectionError("Too many connections") from None + raise MaxConnectionsError("Too many connections") from None connection = self.make_connection() self._in_use_connections.add(connection) return connection