Skip to content

Commit 649c474

Browse files
committed
undo ensure_connection deduplication in BlockingConnectionPool
1 parent 90be214 commit 649c474

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

redis/connection.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,20 @@ def get_connection(self, command_name, *keys, **options):
14771477
connection = self.make_connection()
14781478

14791479
try:
1480-
self.ensure_connection(connection)
1480+
# ensure this connection is connected to Redis
1481+
connection.connect()
1482+
# connections that the pool provides should be ready to send
1483+
# a command. if not, the connection was either returned to the
1484+
# pool before all data has been read or the socket has been
1485+
# closed. either way, reconnect and verify everything is good.
1486+
try:
1487+
if connection.can_read():
1488+
raise ConnectionError("Connection has data")
1489+
except (ConnectionError, OSError):
1490+
connection.disconnect()
1491+
connection.connect()
1492+
if connection.can_read():
1493+
raise ConnectionError("Connection not ready")
14811494
except BaseException:
14821495
# release the connection back to the pool so that we don't leak it
14831496
self.release(connection)

0 commit comments

Comments
 (0)