Url timeout

This commit is contained in:
Alex Yatskov 2016-07-25 22:54:40 -07:00
parent 75a2be931a
commit 3f3ddc59dd

View File

@ -30,6 +30,7 @@ import urllib2
# #
API_VERSION = 1 API_VERSION = 1
URL_TIMEOUT = 10
# #
@ -50,7 +51,7 @@ def audioDownload(kana, kanji):
url += '&kana={}'.format(urllib2.quote(kana.encode('utf-8'))) url += '&kana={}'.format(urllib2.quote(kana.encode('utf-8')))
try: try:
resp = urllib2.urlopen(url) resp = urllib2.urlopen(url, timeout=URL_TIMEOUT)
except urllib2.URLError: except urllib2.URLError:
return None return None