From 2a9628b7355b9b7cb11da2aa5b3d89996aa0b08b Mon Sep 17 00:00:00 2001 From: selsta Date: Fri, 26 Jun 2026 14:51:26 +0200 Subject: [PATCH] functional_tests_rpc: recreate socket for each startup probe --- .../functional_tests/functional_tests_rpc.py | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/functional_tests/functional_tests_rpc.py b/tests/functional_tests/functional_tests_rpc.py index febcf932f..91a7b88a2 100755 --- a/tests/functional_tests/functional_tests_rpc.py +++ b/tests/functional_tests/functional_tests_rpc.py @@ -126,21 +126,19 @@ deadline = time.monotonic() + startup_timeout for port in ports: addr = ('127.0.0.1', port) delay = 0 - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - try: - while True: - timeout = deadline - time.monotonic() - delay - if timeout <= 0: - print('Failed to start wallet or daemon') - kill() - sys.exit(1) - time.sleep(delay) + while True: + time.sleep(delay) + timeout = deadline - time.monotonic() + if timeout <= 0: + print('Failed to start wallet or daemon, last port checked: ' + str(port)) + kill() + sys.exit(1) + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.settimeout(timeout) - if s.connect_ex(addr) == 0: - break - delay = .1 - finally: - s.close() + err = s.connect_ex(addr) + if err == 0: + break + delay = .1 # online daemons need some time to connect to peers to be ready time.sleep(2)