added close methods to everything below transport

This commit is contained in:
Will McGinnis
2016-03-03 19:31:31 -05:00
parent 4de7835d32
commit 8a18e4c743
5 changed files with 41 additions and 0 deletions
@@ -86,3 +86,10 @@ class RequestsHttpConnection(Connection):
self.log_request_success(method, url, response.request.path_url, body, response.status_code, raw_data, duration)
return response.status_code, response.headers, raw_data
def close(self):
"""
Explicitly closes connections
"""
self.session.close()
return True
+6
View File
@@ -113,3 +113,9 @@ class Urllib3HttpConnection(Connection):
return response.status, response.getheaders(), raw_data
def close(self):
"""
Explicitly closes connection
"""
self.pool.close()
return True
+7
View File
@@ -24,3 +24,10 @@ class PoolingConnection(Connection):
def _release_connection(self, con):
self._free_connections.put(con)
def close(self):
"""
Explicitly close connection
"""
return True
+15
View File
@@ -227,6 +227,14 @@ class ConnectionPool(object):
# only one connection, no need for a selector
return connections[0]
def close(self):
"""
Explicitly closes connections
"""
for conn in self.connections:
conn.close()
return True
class DummyConnectionPool(ConnectionPool):
def __init__(self, connections, **kwargs):
@@ -241,6 +249,13 @@ class DummyConnectionPool(ConnectionPool):
def get_connection(self):
return self.connection
def close(self):
"""
Explicitly closes connections
"""
for conn in self.connections:
conn.close()
def _noop(self, *args, **kwargs):
pass
mark_dead = mark_live = resurrect = _noop
+6
View File
@@ -353,3 +353,9 @@ class Transport(object):
data = self.deserializer.loads(data, headers.get('content-type'))
return status, data
def close(self):
"""
Explcitly closes connections
"""
self.connection_pool.close()
return True