2

以下错误是什么意思?

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()

4

0 回答 0