Merge "Cleanup session on delete"
This commit is contained in:
commit
90e71f5506
@ -438,6 +438,15 @@ class HTTPConnection(object):
|
|||||||
if timeout:
|
if timeout:
|
||||||
self.requests_args['timeout'] = timeout
|
self.requests_args['timeout'] = timeout
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
"""Cleanup resources other than memory"""
|
||||||
|
if self.request_session:
|
||||||
|
# The session we create must be closed to free up file descriptors
|
||||||
|
try:
|
||||||
|
self.request_session.close()
|
||||||
|
finally:
|
||||||
|
self.request_session = None
|
||||||
|
|
||||||
def _request(self, *arg, **kwarg):
|
def _request(self, *arg, **kwarg):
|
||||||
"""Final wrapper before requests call, to be patched in tests"""
|
"""Final wrapper before requests call, to be patched in tests"""
|
||||||
return self.request_session.request(*arg, **kwarg)
|
return self.request_session.request(*arg, **kwarg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user