From 3f3ddc59dd9f2e181644e26b73b0152a8b1a3847 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 25 Jul 2016 22:54:40 -0700 Subject: [PATCH] Url timeout --- anki_connect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/anki_connect.py b/anki_connect.py index 0f00361..718f628 100644 --- a/anki_connect.py +++ b/anki_connect.py @@ -30,6 +30,7 @@ import urllib2 # API_VERSION = 1 +URL_TIMEOUT = 10 # @@ -50,7 +51,7 @@ def audioDownload(kana, kanji): url += '&kana={}'.format(urllib2.quote(kana.encode('utf-8'))) try: - resp = urllib2.urlopen(url) + resp = urllib2.urlopen(url, timeout=URL_TIMEOUT) except urllib2.URLError: return None