From 1f639efca5e71a0ff208415d94e408a74778d4db Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Mon, 21 Apr 2025 14:15:34 +0200 Subject: [PATCH] qa: Work around Python socket timeout issue Observed on local machine running Windows / Python v3.13.1 when overriding rpc_timeout to small values (5- seconds). Next commit performs such overrides. --- test/functional/test_framework/test_node.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index dc4efe88df8..953badc3feb 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -322,15 +322,21 @@ class TestNode(): suppressed_errors[f"JSONRPCException {e.error['code']}"] += 1 latest_error = repr(e) except OSError as e: + error_num = e.errno + # Work around issue where socket timeouts don't have errno set. + # https://github.com/python/cpython/issues/109601 + if error_num is None and isinstance(e, TimeoutError): + error_num = errno.ETIMEDOUT + # Suppress similarly to the above JSONRPCException errors. - if e.errno not in [ + if error_num not in [ errno.ECONNRESET, # This might happen when the RPC server is in warmup, # but shut down before the call to getblockcount succeeds. errno.ETIMEDOUT, # Treat identical to ECONNRESET errno.ECONNREFUSED # Port not yet open? ]: raise # unknown OS error - suppressed_errors[f"OSError {errno.errorcode[e.errno]}"] += 1 + suppressed_errors[f"OSError {errno.errorcode[error_num]}"] += 1 latest_error = repr(e) except ValueError as e: # Suppress if cookie file isn't generated yet and no rpcuser or rpcpassword; bitcoind may be starting.