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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user