From 570168ed0e537e1bc67ae346953d57d4221b1a3b Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 19 Jul 2012 01:38:49 -0400 Subject: [PATCH] Institute a timeout so we don't try to open these suspicious URLs forever. --- earwigbot/wiki/copyvios/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/earwigbot/wiki/copyvios/__init__.py b/earwigbot/wiki/copyvios/__init__.py index e89a322..f08b935 100644 --- a/earwigbot/wiki/copyvios/__init__.py +++ b/earwigbot/wiki/copyvios/__init__.py @@ -21,6 +21,7 @@ # SOFTWARE. from gzip import GzipFile +from socket import timeout from StringIO import StringIO from time import sleep, time from urllib2 import build_opener, URLError @@ -64,8 +65,8 @@ class CopyvioMixIn(object): ignored, and the original content is returned. """ try: - response = self._opener.open(url) - except URLError: + response = self._opener.open(url, timeout=5) + except (URLError, timeout): return None result = response.read()