From b13b92bc2dee902e6f9be5bc099e5640a470ebf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 19 Sep 2022 13:48:29 +0000 Subject: [PATCH] connection.connect() now has its own retry, don't need it inside a retry loop --- redis/asyncio/client.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py index 6a01d5eb6b..c13054b227 100644 --- a/redis/asyncio/client.py +++ b/redis/asyncio/client.py @@ -756,19 +756,21 @@ async def parse_response(self, block: bool = True, timeout: float = 0): await self.check_health() - async def try_read(): - if not conn.is_connected: - await conn.connect() - if not block: + if not conn.is_connected: + await conn.connect() + + if not block: + + async def read_with_timeout(): try: async with async_timeout.timeout(timeout): return await conn.read_response() except asyncio.TimeoutError: return None - else: - return await conn.read_response() - response = await self._execute(conn, try_read) + response = await self._execute(conn, read_with_timeout) + else: + response = await self._execute(conn, conn.read_response) if conn.health_check_interval and response == self.health_check_response: # ignore the health check message as user might not expect it