Browse Source

Institute a timeout so we don't try to open these suspicious URLs forever.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
570168ed0e
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      earwigbot/wiki/copyvios/__init__.py

+ 3
- 2
earwigbot/wiki/copyvios/__init__.py View File

@@ -21,6 +21,7 @@
# SOFTWARE. # SOFTWARE.


from gzip import GzipFile from gzip import GzipFile
from socket import timeout
from StringIO import StringIO from StringIO import StringIO
from time import sleep, time from time import sleep, time
from urllib2 import build_opener, URLError from urllib2 import build_opener, URLError
@@ -64,8 +65,8 @@ class CopyvioMixIn(object):
ignored, and the original content is returned. ignored, and the original content is returned.
""" """
try: try:
response = self._opener.open(url)
except URLError:
response = self._opener.open(url, timeout=5)
except (URLError, timeout):
return None return None
result = response.read() result = response.read()




Loading…
Cancel
Save