以下错误是什么意思?
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='', port=443): Read
timed out.
During handling of the above exception, another exception occurred:
requests.exceptions.ConnectionError:
HTTPSConnectionPool(host='', port=443): Read timed out.
这是我的代码:
def get(url):
while True:
try:
response = session.get(url, timeout=.5).text
break
except requests.exceptions.ReadTimeout:
new_session()
return response
r = get(url)
其中session
是我已完成的会话,new_session()
关闭该会话,并通过requests.session()
将会话设置为新会话