mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
test: imfamy: Allow broken images
If ping succeed but fail to check if netconf port is open, the testsystem will hang forever. This will allow totally broken images to be loaded at the device.
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import socket
|
||||
|
||||
def tcp_port_is_open(host, port):
|
||||
def tcp_port_is_open(host, port, timeout=3):
|
||||
try:
|
||||
ai = socket.getaddrinfo(host, port, 0, 0, socket.SOL_TCP)
|
||||
sock = socket.socket(ai[0][0], ai[0][1], 0)
|
||||
sock.connect(ai[0][4])
|
||||
sock.close()
|
||||
return True
|
||||
except Exception:
|
||||
with socket.create_connection((host, port), timeout=timeout):
|
||||
return True
|
||||
except (socket.timeout, OSError):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user