summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chimere/utils.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/chimere/utils.py b/chimere/utils.py
index ba0f205..ffa5789 100644
--- a/chimere/utils.py
+++ b/chimere/utils.py
@@ -50,6 +50,8 @@ from django.utils.translation import ugettext_lazy as _
from chimere import get_version
+TIMEOUT = 20
+
def unicode_normalize(string):
return ''.join(
@@ -202,7 +204,7 @@ class ImportManager(object):
url = source
if extra_url:
url += extra_url
- remotehandle = urllib.request.urlopen(url)
+ remotehandle = urllib.request.urlopen(url, timeout=TIMEOUT)
source = io.BytesIO(remotehandle.read())
remotehandle.close()
except ValueError:
@@ -1195,7 +1197,7 @@ class HtmlXsltManager(ImportManager):
self.marker_cls = Marker
try:
main_page = urllib.request.urlopen(self.importer_instance.source,
- timeout=20)
+ timeout=TIMEOUT)
assert main_page.getcode() == 200
except (urllib.error.URLError, AssertionError):
return (0, 0, _("Source page is unreachable."))
@@ -1243,7 +1245,8 @@ class HtmlXsltManager(ImportManager):
not c_item['link'].startswith('https://'):
c_item['link'] = base_url + c_item['link']
try:
- child_page = urllib.request.urlopen(c_item['link'])
+ child_page = urllib.request.urlopen(c_item['link'],
+ timeout=TIMEOUT)
assert child_page.getcode() == 200
except (urllib.error.URLError, AssertionError):
# don't stop the export for a bad link