Commit 263d904d authored by Łukasz Nowak's avatar Łukasz Nowak

- use quite short timeout while fetching external source


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35990 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3f82c651
...@@ -3,6 +3,7 @@ from urllib2 import HTTPPasswordMgrWithDefaultRealm, HTTPBasicAuthHandler, \ ...@@ -3,6 +3,7 @@ from urllib2 import HTTPPasswordMgrWithDefaultRealm, HTTPBasicAuthHandler, \
from xml.dom.minidom import parseString from xml.dom.minidom import parseString
import md5 import md5
from HTMLParser import HTMLParser from HTMLParser import HTMLParser
import socket
def getRssDataAsDict(url, username, password): def getRssDataAsDict(url, username, password):
passman = HTTPPasswordMgrWithDefaultRealm() passman = HTTPPasswordMgrWithDefaultRealm()
...@@ -11,7 +12,13 @@ def getRssDataAsDict(url, username, password): ...@@ -11,7 +12,13 @@ def getRssDataAsDict(url, username, password):
opener = build_opener(auth_handler) opener = build_opener(auth_handler)
install_opener(opener) install_opener(opener)
try: try:
file = urlopen(url) default_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(5.0)
try:
file = urlopen(url)
finally:
socket.setdefaulttimeout(default_timeout)
except IOError , e: except IOError , e:
return {'title': 'Connection problem, please retry later.'} return {'title': 'Connection problem, please retry later.'}
except ValueError , e: except ValueError , e:
......
518 519
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment