gpt4 book ai didi

Python - urllib2 超时

转载 作者:太空宇宙 更新时间:2023-11-03 14:34:23 24 4
gpt4 key购买 nike

下面是我的代码片段

opener = urllib2.build_opener(redirect_handler.MyHTTPRedirectHandler())
opener.addheaders = [('Accept-encoding', 'gzip')]
fetch_timeout = 12
self.response = opener.open(url, timeout=fetch_timeout)

然而,它的代码在超时之前仍然等待 60~ 秒...有什么线索吗?

最佳答案

我猜你可能需要设置套接字超时

import socket

default_timeout = 12

socket.setdefaulttimeout(default_timeout)

关于Python - urllib2 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4207983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com