Skip to content

Commit

Permalink
[test] Work around random "Failed to establish a new connection" errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmlnkn committed Oct 12, 2024
1 parent e1d0f7c commit 06c81f5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/wait-for-port.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
n = max(1, int(math.ceil(timeout / 5)))
for i in range(n):
if sock.connect_ex(("127.0.0.1", int(sys.argv[1]))) == 0:
print(f"Weed port opened after {time.time() - t0:.1f} s.")
sys.exit(0)
try:
if sock.connect_ex(("127.0.0.1", int(sys.argv[1]))) == 0:
print(f"Weed port opened after {time.time() - t0:.1f} s.")
sys.exit(0)
except Exception:
pass
# Do not wait after the last test.
if i < n - 1:
time.sleep(5)
Expand Down

0 comments on commit 06c81f5

Please sign in to comment.