mirror of
https://opendev.org/x/pyghmi
synced 2025-01-14 19:57:47 +00:00
Set a 60 second timeout on web
Web connections were defaulting to infinite timeout. If a problem happened in the midst of a connection, a request could hang things indefinitely. Add a 60 second timeout to purge these situations. Change-Id: Ica05e2bfb9242ccc564e39c8631d8bf7e3f230a5
This commit is contained in:
parent
a363bd92fb
commit
7fc07debf8
@ -35,6 +35,8 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
|
||||
def __init__(self, host, port=None, key_file=None, cert_file=None,
|
||||
ca_certs=None, strict=None, verifycallback=None, **kwargs):
|
||||
if 'timeout' not in kwargs:
|
||||
kwargs['timeout'] = 60
|
||||
httplib.HTTPConnection.__init__(self, host, port, strict, **kwargs)
|
||||
self.cert_reqs = ssl.CERT_NONE # verification will be done ssh style..
|
||||
self._certverify = verifycallback
|
||||
@ -45,7 +47,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
self.stdheaders[key] = value
|
||||
|
||||
def connect(self):
|
||||
plainsock = socket.create_connection((self.host, self.port))
|
||||
plainsock = socket.create_connection((self.host, self.port), 60)
|
||||
self.sock = ssl.wrap_socket(plainsock, cert_reqs=self.cert_reqs)
|
||||
# txtcert = self.sock.getpeercert() # currently not possible
|
||||
bincert = self.sock.getpeercert(binary_form=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user