Skip to content
2 changes: 1 addition & 1 deletion redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ async def ensure_connection(self, connection: AbstractConnection):
try:
if await connection.can_read_destructive():
raise ConnectionError("Connection has data") from None
except (ConnectionError, OSError):
except (ConnectionError, TimeoutError, OSError):
await connection.disconnect()
await connection.connect()
if await connection.can_read_destructive():
Expand Down
4 changes: 2 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ def get_connection(self, command_name=None, *keys, **options) -> "Connection":
try:
if connection.can_read() and self.cache is None:
raise ConnectionError("Connection has data")
except (ConnectionError, OSError):
except (ConnectionError, TimeoutError, OSError):
connection.disconnect()
connection.connect()
if connection.can_read():
Expand Down Expand Up @@ -1741,7 +1741,7 @@ def get_connection(self, command_name=None, *keys, **options):
try:
if connection.can_read():
raise ConnectionError("Connection has data")
except (ConnectionError, OSError):
except (ConnectionError, TimeoutError, OSError):
connection.disconnect()
connection.connect()
if connection.can_read():
Expand Down
Loading