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()
...@@ -10,8 +11,14 @@ def getRssDataAsDict(url, username, password): ...@@ -10,8 +11,14 @@ def getRssDataAsDict(url, username, password):
auth_handler = HTTPBasicAuthHandler(passman) auth_handler = HTTPBasicAuthHandler(passman)
opener = build_opener(auth_handler) opener = build_opener(auth_handler)
install_opener(opener) install_opener(opener)
try:
default_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(5.0)
try: try:
file = urlopen(url) 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