Skip to content

Commit 882881f

Browse files
committed
connection.connect() now has its own retry, don't need it inside a retry loop
1 parent 3121525 commit 882881f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

redis/asyncio/client.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,19 +756,21 @@ async def parse_response(self, block: bool = True, timeout: float = 0):
756756

757757
await self.check_health()
758758

759-
async def try_read():
760-
if not conn.is_connected:
761-
await conn.connect()
762-
if not block:
759+
if not conn.is_connected:
760+
await conn.connect()
761+
762+
if not block:
763+
764+
async def read_with_timeout():
763765
try:
764766
async with async_timeout.timeout(timeout):
765767
return await conn.read_response()
766768
except asyncio.TimeoutError:
767769
return None
768-
else:
769-
return await conn.read_response()
770770

771-
response = await self._execute(conn, try_read)
771+
response = await self._execute(conn, read_with_timeout)
772+
else:
773+
response = await self._execute(conn, conn.read_response)
772774

773775
if conn.health_check_interval and response == self.health_check_response:
774776
# ignore the health check message as user might not expect it

0 commit comments

Comments
 (0)