jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Use only a single timeout
......................................................................
[FIX] Use only a single timeout
On older installations of requests it's not possible to use two timeout values.
It is now using only one timeout value (of 30 seconds) for both by default and
it emits a warning when a tuple was used and the requests version is to old.
Bug: T103069
Change-Id: I14c9a3992b0283f6402fae851182e4db0b84a251
---
M pywikibot/comms/http.py
M pywikibot/config2.py
2 files changed, 10 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 1ddb029..50343a1 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -25,6 +25,7 @@
import atexit
import sys
+from distutils.version import StrictVersion
from string import Formatter
from warnings import warn
@@ -57,6 +58,13 @@
_logger = "comm.http"
+if (isinstance(pywikibot.config2.socket_timeout, tuple) and
+ StrictVersion(requests.__version__) < StrictVersion('2.4.0')):
+ pywikibot.warning('The configured timeout is a tuple but requests does not
'
+ 'support a tuple as a timeout. It uses the lower of the '
+ 'two.')
+ pywikibot.config2.socket_timeout = min(pywikibot.config2.socket_timeout)
+
session = requests.Session()
cookie_jar = cookielib.LWPCookieJar(
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 5ac6ec6..7912952 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -696,8 +696,8 @@
# Default socket timeout in seconds.
# DO NOT set to None to disable timeouts. Otherwise this may freeze your
script.
# You may assign either a tuple of two int or float values for connection and
-# read timeout, or a single value for both.
-socket_timeout = (30, 120)
+# read timeout, or a single value for both in a tuple (since requests 2.4.0).
+socket_timeout = 30
# ############# COSMETIC CHANGES SETTINGS ##############
--
To view, visit https://gerrit.wikimedia.org/r/219441
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I14c9a3992b0283f6402fae851182e4db0b84a251
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits