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):
11801180 new_connections .remove (connection )
11811181 self ._connections = new_connections
11821182
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 :
11911191 self ._trash .add (connection )
11921192
11931193 if did_trash :
You can’t perform that action at this time.
0 commit comments