PyCurl的默认超时时间是多少?

4

我认为问题的标题已经很明确了,所以您可能不需要继续阅读,但以下是内容:

我已经使用PyCurl很长一段时间了,我一直使用下面的方法来设置超时时间:

curlConnector = pycurl.Curl()
curlConnector.setopt(pycurl.CONNECTTIMEOUT, 30)

但我开始想知道默认的超时时间是多少,或者如何找到它,目前我还没有看到令人满意的答案。如果我没有手动指定超时时间,默认超时时间是多少?是来自于 socket 吗?(如果有关的话,我在 Ubuntu 12.04 上工作,使用的是 python2.7)

1个回答

7

我下载了PyCurl。在tarball的doc/目录中,有几个文档文件。其中之一是doc/curlobject.html,它说setup“对应于libcurl中的curl_easy_setopt”。点击该链接会跳转到http://curl.haxx.se/libcurl/c/curl_easy_setopt.html,搜索'CONNECTTIMEOUT'后,可以看到:

CURLOPT_CONNECTTIMEOUT

Pass a long. It should contain the maximum time in seconds that you allow the connection to the server to take. 
This only limits the connection phase, once it has connected, this option is of no more use. 
Set to zero to switch to the default built-in connection timeout - 300 seconds. 
See also the CURLOPT_TIMEOUT option.

因此,我认为默认超时时间为300秒。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接