Skip to content

Commit

Permalink
connection.connect() now has its own retry, don't need it inside a re…
Browse files Browse the repository at this point in the history
…try loop
  • Loading branch information
kristjanvalur committed Sep 29, 2022
1 parent 3121525 commit 882881f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 882881f

Please sign in to comment.