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