From 09b53bebe96252acb95156d59897fd05bd2d1ab5 Mon Sep 17 00:00:00 2001 From: test123456654321 <16307130148@fudan.edu.cn> Date: Sat, 26 Oct 2024 13:33:02 +0800 Subject: [PATCH] timeout --- src/LunaTranslator/gui/setting_about.py | 8 +++++++- src/LunaTranslator/requests.py | 8 ++++---- src/plugins/CMakeLists.txt | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/LunaTranslator/gui/setting_about.py b/src/LunaTranslator/gui/setting_about.py index 6cb7f65b..873e44f1 100644 --- a/src/LunaTranslator/gui/setting_about.py +++ b/src/LunaTranslator/gui/setting_about.py @@ -115,7 +115,13 @@ def updatemethod(urls, self): return savep with open(savep, "wb") as file: sess = requests.session() - r = sess.get(url, stream=True, verify=False, proxies=getproxy(("update", __x))) + r = sess.get( + url, + stream=True, + verify=False, + proxies=getproxy(("update", __x)), + timeout=None, + ) file_size = 0 for i in r.iter_content(chunk_size=1024): if check_interrupt(): diff --git a/src/LunaTranslator/requests.py b/src/LunaTranslator/requests.py index 20bc4413..e662f9b4 100644 --- a/src/LunaTranslator/requests.py +++ b/src/LunaTranslator/requests.py @@ -7,6 +7,8 @@ from myutils.config import globalconfig default_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" +default_timeout = 10 + class RequestException(Exception): pass @@ -257,7 +259,7 @@ class Requester_common: cookies=None, files=None, auth=None, - timeout=None, + timeout=default_timeout, allow_redirects=True, hooks=None, stream=None, @@ -290,8 +292,6 @@ class Requester_common: headers["Content-Type"] = contenttype proxy = proxies.get(scheme, None) if proxies else None proxy = None if proxy == "" else proxy - if timeout is None: - timeout = 10 if timeout: if isinstance(timeout, (float, int)): timeout = int(timeout * 1000) # convert to milliseconds @@ -470,7 +470,7 @@ class Session: cookies=None, files=None, auth=None, - timeout=None, + timeout=default_timeout, allow_redirects=True, hooks=None, stream=None, diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 6ffc2cd3..419a5516 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 50) -set(VERSION_PATCH 0) +set(VERSION_PATCH 1) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)