You can set the timeout in Plone, but that is not a good idea as you sometime need long running processes to end properly, eg for packing etc.
A workaround is spwaning seperate threads and callback routines. But that is a bother to set up.
Suddenly it stroke me today that it would be possible to change the timout temporarily for a single thread:
import socket
import feedparser
def parseUrl(self, url):
"Fetch the url"
orig_timout = socket.getdefaulttimeout() # get original timeout
# give it a 20 second timout
socket.setdefaulttimeout(20) # set to 20 seconds
try:
result = feedparser.parse(url)['entries']
except:
result = []
socket.setdefaulttimeout(orig_timout) # set back to original
endresult = []
for r in result:
r2 = {}
r2.update(r)
endresult.append(r2)
# sort for latest first
decorated = [(r['updated_parsed'], r) for r in endresult]
decorated.sort()
decorated.reverse()
sorted = [d[-1] for d in decorated]
return sorted
Sweet and simple ...