Xqt has uploaded a new change for review. https://gerrit.wikimedia.org/r/218616
Change subject: [bugfix] Timeout session.requests ...................................................................... [bugfix] Timeout session.requests With 2.1 release requests library was introduced but there is no default timout. Without any timeout setting, scripts may freeze. Re-use old config.socket_timeout but take a float value for the new library. Keep compatible if an int value is given until now. Bug: T91236 Bug: T102462 Bug: T102113 Change-Id: Iaa7fb4cc8970b6b9ad8b191f2106104fcf7f8884 --- M pywikibot/comms/http.py M pywikibot/config2.py 2 files changed, 9 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/16/218616/1 diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 6663462..949acea 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -244,10 +244,13 @@ uri = http_request.uri body = http_request.body headers = http_request.headers + timeout = config.socket_timeout + if not isinstance(timeout, tuple): + timeout = float(timeout) # keep compatible with previous setting try: request = session.request(method, uri, data=body, headers=headers, - verify=True) + verify=True, timeout=timeout) except Exception as e: http_request.data = e else: diff --git a/pywikibot/config2.py b/pywikibot/config2.py index d70f780..4fe24b6 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -706,8 +706,11 @@ # DISABLED FUNCTION. Setting this variable will not have any effect. persistent_http = False -# Default socket timeout. Set to None to disable timeouts. -socket_timeout = 120 # set a pretty long timeout just in case... +# Default socket timeout. +# DO NOT set to None to disable timeouts. Otherwise this may freeze your script. +# You may assign either a tuple of two float values for connection and read +# timeout, or a single float value for both. +socket_timeout = 120.0 # set a pretty long timeout just in case... # ############# COSMETIC CHANGES SETTINGS ############## -- To view, visit https://gerrit.wikimedia.org/r/218616 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa7fb4cc8970b6b9ad8b191f2106104fcf7f8884 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Xqt <i...@gno.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits