@@ -1098,7 +1098,7 @@ def __repr__(self):
1098
1098
)
1099
1099
1100
1100
def reset (self ):
1101
- self ._lock = threading .RLock ()
1101
+ self ._lock = threading .Lock ()
1102
1102
self ._created_connections = 0
1103
1103
self ._available_connections = []
1104
1104
self ._in_use_connections = set ()
@@ -1177,28 +1177,29 @@ def get_connection(self, command_name, *keys, **options):
1177
1177
except IndexError :
1178
1178
connection = self .make_connection ()
1179
1179
self ._in_use_connections .add (connection )
1180
+
1181
+ try :
1182
+ # ensure this connection is connected to Redis
1183
+ connection .connect ()
1184
+ # connections that the pool provides should be ready to send
1185
+ # a command. if not, the connection was either returned to the
1186
+ # pool before all data has been read or the socket has been
1187
+ # closed. either way, reconnect and verify everything is good.
1180
1188
try :
1181
- # ensure this connection is connected to Redis
1189
+ if connection .can_read ():
1190
+ raise ConnectionError ('Connection has data' )
1191
+ except ConnectionError :
1192
+ connection .disconnect ()
1182
1193
connection .connect ()
1183
- # connections that the pool provides should be ready to send
1184
- # a command. if not, the connection was either returned to the
1185
- # pool before all data has been read or the socket has been
1186
- # closed. either way, reconnect and verify everything is good.
1187
- try :
1188
- if connection .can_read ():
1189
- raise ConnectionError ('Connection has data' )
1190
- except ConnectionError :
1191
- connection .disconnect ()
1192
- connection .connect ()
1193
- if connection .can_read ():
1194
- raise ConnectionError ('Connection not ready' )
1195
- except BaseException :
1196
- # release the connection back to the pool so that we don't
1197
- # leak it
1198
- self .release (connection )
1199
- raise
1200
-
1201
- return connection
1194
+ if connection .can_read ():
1195
+ raise ConnectionError ('Connection not ready' )
1196
+ except BaseException :
1197
+ # release the connection back to the pool so that we don't
1198
+ # leak it
1199
+ self .release (connection )
1200
+ raise
1201
+
1202
+ return connection
1202
1203
1203
1204
def get_encoder (self ):
1204
1205
"Return an encoder based on encoding settings"
0 commit comments