这是一个创建于 4484 天前的主题,其中的信息可能已经有所发展或是发生改变。
用douban-python在做一个基于豆瓣API的应用,用下面的代码说一下问题:
由于网络问题,请求经常会发不出去或者收不到response,也就是有时候运行到 feed = client.GetContacts(url) 就卡住了,看了一下douban-python提供的 GetContacts() 函数,好像也没有提供timeout参数,但是我想如果一次请求20秒还没有收到请求的话,就放弃请求并继续执行程序,请问如何实现?感谢!
2 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
VeryCB 2012-06-28 22:36:18 +08:00
写错了,是“一次请求20秒还没有收到回复”
|
|
|
2
for4 2012-06-28 22:40:10 +08:00
没看过douban-python. 试试这个? socket.setdefaulttimeout(20)
|