Close streamed requests explicitly

If we don't explicitly close a response after streaming its download,
then we can run into HTTPConnectionPool full warnings. It also will hurt
performance if we have to continuously create new sockets for new
responses. Calling close will return the connection to the pool so it
can be reused. Note this is only necessary when streaming a response. If
we don't stream it, then requests will return the connection to the pool
for us.

Change-Id: I803bd4dd0e769c233501d5e5ff07a19705fbe233
Closes-bug: 1341777
This commit is contained in:
Ian Cordasco
2015-01-15 16:09:23 -06:00
parent aebbcff100
commit f2107512ee
2 changed files with 15 additions and 1 deletions
+3
View File
@@ -126,6 +126,9 @@ class FakeResponse(object):
def read(self, amt):
return self.body.read(amt)
def close(self):
pass
@property
def content(self):
if hasattr(self.body, "read"):