Merge pull request #3711 from radarhere/retry

Retry on URLError
This commit is contained in:
Hugo 2019-03-12 13:58:58 +02:00 committed by GitHub
commit 3e9457a034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,11 @@ def fetch(url):
if not os.path.exists(name):
print("Fetching", url)
content = urllib.request.urlopen(url).read()
try:
r = urllib.request.urlopen(url)
except urllib.error.URLError:
r = urllib.request.urlopen(url)
content = r.read()
with open(name, 'wb') as fd:
fd.write(content)
return name