Skip to content

Commit 88501a0

Browse files
committed
undo ensure_connection deduplication in BlockingConnectionPool
1 parent a4601a7 commit 88501a0

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
@@ -1483,7 +1483,20 @@ def get_connection(self, command_name, *keys, **options):
14831483
connection = self.make_connection()
14841484

14851485
try:
1486-
self.ensure_connection(connection)
1486+
# ensure this connection is connected to Redis
1487+
connection.connect()
1488+
# connections that the pool provides should be ready to send
1489+
# a command. if not, the connection was either returned to the
1490+
# pool before all data has been read or the socket has been
1491+
# closed. either way, reconnect and verify everything is good.
1492+
try:
1493+
if connection.can_read():
1494+
raise ConnectionError("Connection has data")
1495+
except (ConnectionError, OSError):
1496+
connection.disconnect()
1497+
connection.connect()
1498+
if connection.can_read():
1499+
raise ConnectionError("Connection not ready")
14871500
except BaseException:
14881501
# release the connection back to the pool so that we don't leak it
14891502
self.release(connection)

0 commit comments

Comments
 (0)