Commit 66ad9c9e authored by Jalin's avatar Jalin

增加网络默认超时时间

parent e81a2396
......@@ -90,6 +90,9 @@ class Config:
CDN_ITEM_FILE = PROJECT_DIR + 'data/cdn.txt'
CDN_ENABLED_AVAILABLE_ITEM_FILE = QUERY_DATA_DIR + 'available.json'
# Default time out
TIME_OUT_OF_REQUEST = 5
envs = []
retry_time = 5
last_modify_time = 0
......
......@@ -53,6 +53,9 @@ class Request(HTMLSession):
def request(self, *args, **kwargs): # 拦截所有错误
try:
if not 'timeout' in kwargs:
from py12306.config import Config
kwargs['timeout'] = Config().TIME_OUT_OF_REQUEST
response = super().request(*args, **kwargs)
return response
except RequestException as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment