Catch exceptions when draining the connection before retry/redirect
MODIFY
urllib3/connectionpool.py
urllib3/connectionpool.py
@@ -667,8 +667,13 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
**response_kw)
def drain_and_release_conn(response):
+ try:
+ # discard any remaining response body, the connection will be
+ # released back to the pool once the entire response is read
response.read()
- response.release_conn()
+ except (TimeoutError, HTTPException, SocketError, ProtocolError,
+ BaseSSLError, SSLError) as e:
+ pass
# Handle redirect?
redirect_location = redirect and response.get_redirect_location()

Catch exceptions when draining the connection before retry/redirect