From a16b3c8016a106c957c4fdcd6e42659fdf203caa Mon Sep 17 00:00:00 2001 From: SNeedlewoods Date: Thu, 13 Aug 2026 16:14:27 +0200 Subject: [PATCH] functional_tests: remove unreachable code, kill process after timeout Co-authored-by: selsta --- .../functional_tests/functional_tests_rpc.py | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tests/functional_tests/functional_tests_rpc.py b/tests/functional_tests/functional_tests_rpc.py index 91a7b88a2..ad21de725 100755 --- a/tests/functional_tests/functional_tests_rpc.py +++ b/tests/functional_tests/functional_tests_rpc.py @@ -161,24 +161,14 @@ for test in tests: print('Stopping servers...') kill() -# wait for exit, the poll method does not work (https://bugs.python.org/issue2475) so we wait, possibly forever if the process hangs -if True: - for p in processes: +# Wait up to 10 seconds for each process, then force termination. +for p in processes: + try: + p.wait(timeout=10) + except subprocess.TimeoutExpired: + print('Failed to stop process ' + str(p.pid) + ', killing it') + p.kill() p.wait() -else: - for i in range(10): - n_returncode = 0 - for p in processes: - p.poll() - if p.returncode: - n_returncode += 1 - if n_returncode == len(processes): - print('All done: ' + string.join([x.returncode for x in processes], ', ')) - break - time.sleep(1) - for p in processes: - if not p.returncode: - print('Failed to stop process') if len(FAIL) == 0: print('Done, ' + str(len(PASS)) + '/' + str(len(tests)) + ' tests passed')