Skip to content

Commit 85da67a

Browse files
authored
Merge pull request #1243 from kernelkit/allow-tests-to-fail
test: imfamy: Allow broken images
2 parents 764bd8e + 357950b commit 85da67a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/infamy/netutil.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import socket
22

3-
def tcp_port_is_open(host, port):
3+
def tcp_port_is_open(host, port, timeout=3):
44
try:
5-
ai = socket.getaddrinfo(host, port, 0, 0, socket.SOL_TCP)
6-
sock = socket.socket(ai[0][0], ai[0][1], 0)
7-
sock.connect(ai[0][4])
8-
sock.close()
9-
return True
10-
except Exception:
5+
with socket.create_connection((host, port), timeout=timeout):
6+
return True
7+
except (socket.timeout, OSError):
118
return False

0 commit comments

Comments
 (0)