Close and then release the connection

urllib3 closes the underlying connection when we call
urllib3.Response.close but does not release it back to the connection
pool. This can cause issues when users have a blocking connection pool
configured and connections are not readily returned to the pool.

Since the underlying connection is closed, we should be able to safely
return the connection to the connection pool, so to fix this issue we
merely need to not return after closing the response.

Closes gh-3461
This commit is contained in:
Ian Cordasco
2016-07-30 07:16:18 -05:00
parent f40764c01b
commit c69e3eed31
+1 -1
View File
@@ -868,6 +868,6 @@ class Response(object):
*Note: Should not normally need to be called explicitly.*
"""
if not self._content_consumed:
return self.raw.close()
self.raw.close()
return self.raw.release_conn()