From e518f2ccedee33a2f2ddd08d34183a0370fce6cf Mon Sep 17 00:00:00 2001 From: pictuga Date: Sun, 5 May 2013 15:31:11 +0200 Subject: [PATCH] Better timeout error handling For older versions of Python --- morss.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/morss.py b/morss.py index 72139b6..4b0b9ca 100644 --- a/morss.py +++ b/morss.py @@ -15,6 +15,7 @@ import lxml.html.clean import lxml.builder import urllib2 +import socket from cookielib import CookieJar import chardet @@ -283,7 +284,7 @@ def EncDownload(url): opener.addheaders = [('User-Agent', UA_HML)] con = opener.open(url, timeout=TIMEOUT) data = con.read() - except (urllib2.HTTPError, urllib2.URLError) as error: + except (urllib2.HTTPError, urllib2.URLError, socket.timeout) as error: log(error) return False