欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python中為feedparser設(shè)置超時(shí)時(shí)間避免堵塞

 更新時(shí)間:2014年09月28日 17:53:12   投稿:whsnow  
為feedparser設(shè)置一個(gè)超時(shí)時(shí)間,可是feedparser并沒有提供這個(gè)功能,只好采用其他方法了,感興趣的朋友可以看看

python有一個(gè)用于解析feed的模塊:feedparser,feedparser解析各種feed是非常方便的,唯一比較惱火的是遇到一些badurl,經(jīng)常會(huì)導(dǎo)致堵塞,因此需要為feedparser設(shè)置一個(gè)超時(shí)時(shí)間。

可是feedparser并沒有提供這個(gè)功能,只好采用其他方法了,具體辦法請(qǐng)參看feedparser項(xiàng)目的issue221。

其實(shí)也很簡(jiǎn)單,按照上面文檔的說明

developers have had the ability to set a global timeout for over seven years by importing the socket library and setting the timeout in this way:

復(fù)制代碼 代碼如下:

import socket
socket.setdefaulttimeout(<timeout in floating seconds>)

相關(guān)文章

最新評(píng)論