catch ConnectionRefused also
This commit is contained in:
parent
9fbe0a129c
commit
42cc6850b2
@ -22,7 +22,7 @@ def try_connect(ip: str) -> bool:
|
||||
sock = None
|
||||
try:
|
||||
sock = socket.create_connection((ip, 22), 1)
|
||||
except socket.timeout:
|
||||
except (socket.timeout, ConnectionRefusedError):
|
||||
return False
|
||||
sock.close()
|
||||
return True
|
||||
@ -88,6 +88,7 @@ ip = list(filter(lambda x: ip_address(x).version == 4, ips))[0]
|
||||
|
||||
while not try_connect(ip):
|
||||
print('Waiting for SSH service to become available...')
|
||||
sleep(4)
|
||||
pass
|
||||
|
||||
open_conn(ip)
|
||||
|
Loading…
Reference in New Issue
Block a user