Clean up socket on deletion

Some resources are leaked on deletion
of a webclient without explicit close, improve
by destructor.

Change-Id: I91d313125bf79f83c3cd07e12e573b2bdd5a95ef
This commit is contained in:
Jarrod Johnson
2022-05-18 16:26:45 -04:00
parent 582598c2ef
commit d286a8326a

View File

@@ -151,6 +151,11 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
if '[' not in host and '%' in host and 'Host'not in self.stdheaders:
self.stdheaders['Host'] = '[' + host[:host.find('%')] + ']'
def __del__(self):
if self.sock:
self.sock.close()
self.sock = None
def dupe(self):
return SecureHTTPConnection(self.thehost, self.theport, clone=self,
timeout=self.mytimeout)