Better timeout error handling

For older versions of Python
master
pictuga 2013-05-05 15:31:11 +02:00
parent 03501edccd
commit e518f2cced
1 changed files with 2 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import lxml.html.clean
import lxml.builder import lxml.builder
import urllib2 import urllib2
import socket
from cookielib import CookieJar from cookielib import CookieJar
import chardet import chardet
@ -283,7 +284,7 @@ def EncDownload(url):
opener.addheaders = [('User-Agent', UA_HML)] opener.addheaders = [('User-Agent', UA_HML)]
con = opener.open(url, timeout=TIMEOUT) con = opener.open(url, timeout=TIMEOUT)
data = con.read() data = con.read()
except (urllib2.HTTPError, urllib2.URLError) as error: except (urllib2.HTTPError, urllib2.URLError, socket.timeout) as error:
log(error) log(error)
return False return False