diff --git a/jenkins/__init__.py b/jenkins/__init__.py index 7ebdbea..3f9c209 100755 --- a/jenkins/__init__.py +++ b/jenkins/__init__.py @@ -58,6 +58,7 @@ import warnings import multi_key_dict import requests import requests.exceptions as req_exc +import urllib3.util.timeout from requests.packages.urllib3.exceptions import InsecureRequestWarning from six.moves.http_client import BadStatusLine from six.moves.urllib.error import URLError @@ -91,6 +92,7 @@ LAUNCHER_COMMAND = 'hudson.slaves.CommandLauncher' LAUNCHER_JNLP = 'hudson.slaves.JNLPLauncher' LAUNCHER_WINDOWS_SERVICE = 'hudson.os.windows.ManagedWindowsServiceLauncher' DEFAULT_HEADERS = {'Content-Type': 'text/xml; charset=utf-8'} +DEFAULT_TIMEOUT = getattr(urllib3.util.timeout, '_DEFAULT_TIMEOUT', socket._GLOBAL_DEFAULT_TIMEOUT) # REST Endpoints INFO = 'api/json' @@ -300,7 +302,7 @@ class Jenkins(object): _timeout_warning_issued = False def __init__(self, url, username=None, password=None, - timeout=socket._GLOBAL_DEFAULT_TIMEOUT): + timeout=DEFAULT_TIMEOUT): '''Create handle to Jenkins instance. All methods will raise :class:`JenkinsException` on failure. @@ -2247,7 +2249,7 @@ class Jenkins(object): raise ValueError("Timeout must be >= 0 not %d" % timeout) if (not self._timeout_warning_issued and - self.timeout != socket._GLOBAL_DEFAULT_TIMEOUT and + self.timeout != DEFAULT_TIMEOUT and timeout < self.timeout): warnings.warn("Requested timeout to wait for jenkins to resume " "normal operations is less than configured "