Skip to content

Commit 1f639ef

Browse files
committed
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.
1 parent 9b24a40 commit 1f639ef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/functional/test_framework/test_node.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,21 @@ def wait_for_rpc_connection(self, *, wait_for_import=True):
322322
suppressed_errors[f"JSONRPCException {e.error['code']}"] += 1
323323
latest_error = repr(e)
324324
except OSError as e:
325+
error_num = e.errno
326+
# Work around issue where socket timeouts don't have errno set.
327+
# https://github.com/python/cpython/issues/109601
328+
if error_num is None and isinstance(e, TimeoutError):
329+
error_num = errno.ETIMEDOUT
330+
325331
# Suppress similarly to the above JSONRPCException errors.
326-
if e.errno not in [
332+
if error_num not in [
327333
errno.ECONNRESET, # This might happen when the RPC server is in warmup,
328334
# but shut down before the call to getblockcount succeeds.
329335
errno.ETIMEDOUT, # Treat identical to ECONNRESET
330336
errno.ECONNREFUSED # Port not yet open?
331337
]:
332338
raise # unknown OS error
333-
suppressed_errors[f"OSError {errno.errorcode[e.errno]}"] += 1
339+
suppressed_errors[f"OSError {errno.errorcode[error_num]}"] += 1
334340
latest_error = repr(e)
335341
except ValueError as e:
336342
# Suppress if cookie file isn't generated yet and no rpcuser or rpcpassword; bitcoind may be starting.

0 commit comments

Comments
 (0)