2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 03:19:48 +00:00

Fix api client attempts and speed up checking connections

This commit is contained in:
Jarrod Johnson 2021-10-18 16:31:59 -04:00
parent ae7e69d73d
commit 6e7b6188dd

View File

@ -155,15 +155,21 @@ class HTTPSClient(client.HTTPConnection, object):
hosts.append(self.v4srv)
if self.v6srv:
hosts.append(self.v6srv)
for host in hosts:
try:
addrinf = socket.getaddrinfo(host, self.port)[0]
psock = socket.socket(addrinf[0])
psock.connect(addrinf[4])
foundsrv = host
psock.close()
except OSError:
for timeo in (0.1, 10):
for host in hosts:
try:
addrinf = socket.getaddrinfo(host, self.port)[0]
psock = socket.socket(addrinf[0])
psock.settimeout(timeo)
psock.connect(addrinf[4])
foundsrv = host
psock.close()
break
except OSError:
continue
else:
continue
break
if not foundsrv:
raise Exception('Unable to reach any hosts')
return foundsrv