From bbcab99b4d83f9316b7da0ca6adaee53e4dccdc8 Mon Sep 17 00:00:00 2001 From: taoky Date: Mon, 13 Jan 2025 21:12:46 +0800 Subject: [PATCH] Fix timeout setting in CustomXMLRPCTransport --- shadowmire.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shadowmire.py b/shadowmire.py index 48c1d8a..92a023c 100755 --- a/shadowmire.py +++ b/shadowmire.py @@ -24,6 +24,7 @@ import tomllib from copy import deepcopy import functools from http.client import HTTPConnection +import socket import requests import click @@ -298,8 +299,9 @@ class CustomXMLRPCTransport(xmlrpc.client.Transport): def make_connection(self, host: tuple[str, dict[str, str]] | str) -> HTTPConnection: conn = super().make_connection(host) - if conn.timeout is None: - # 2 min timeout + if socket.getdefaulttimeout() is None: + # By default conn.timeout is socket._GLOBAL_DEFAULT_TIMEOUT instead of None. + # So here we check if default timeout is set, and if not, add a 2-min timeout conn.timeout = 120 return conn