File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -1180,14 +1180,14 @@ def _maybe_trash_connection(self, connection):
1180
1180
new_connections .remove (connection )
1181
1181
self ._connections = new_connections
1182
1182
1183
- with connection . lock :
1184
- if connection .in_flight == 0 :
1185
- log . debug ( "Skipping trash and closing unused connection (%s) to %s" , id ( connection ), self . host )
1186
- connection . close ()
1187
-
1188
- # skip adding it to the trash if we're already closing it
1189
- return
1190
-
1183
+ if did_trash :
1184
+ with connection .lock :
1185
+ no_pending_requests = connection . in_flight <= len ( connection . orphaned_request_ids )
1186
+ if no_pending_requests :
1187
+ log . debug ( "Skipping trash and closing unused connection (%s) to %s" , id ( connection ), self . host )
1188
+ connection . close ()
1189
+ return
1190
+ with self . _lock :
1191
1191
self ._trash .add (connection )
1192
1192
1193
1193
if did_trash :
You can’t perform that action at this time.
0 commit comments