(Mostly) revert "Cleanup session on delete"

This reverts commit 1f26c57369 for py2.
Apparently the existence of the __del__ method on Python 2 prevents us
from cleaning up all file descriptors.

Change-Id: Id6cff5dd7b9faf9c4240c0cb26b74d05ed37da5b
Closes-Bug: #1873435
Related-Bug: #1838775
This commit is contained in:
Tim Burke 2020-06-17 15:44:22 -07:00
parent 9d8db8f612
commit 0c70d164ba

View File

@ -443,14 +443,16 @@ class HTTPConnection(object):
if 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
if not six.PY2:
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):
"""Final wrapper before requests call, to be patched in tests"""