From 3b235cb540d6f4739af757f41501c9d14d3e5869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Date: Mon, 21 Nov 2016 17:16:48 +0100 Subject: [PATCH] prefetch: gracefully handle HTTPException MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are distinct from urllib’s HTTPErrors --- src/tts_tools/prefetch/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tts_tools/prefetch/__init__.py b/src/tts_tools/prefetch/__init__.py index 265bb22..5e907aa 100644 --- a/src/tts_tools/prefetch/__init__.py +++ b/src/tts_tools/prefetch/__init__.py @@ -1,3 +1,4 @@ +import http.client import os import sys import urllib.request @@ -112,6 +113,10 @@ def prefetch_file(filename, print_err("Error ({reason})".format(reason=error)) continue + except http.client.HTTPException as error: + print_err("HTTP error ({reason})".format(reason=error)) + continue + # Only for informative purposes. length = response.getheader('Content-Length', 0) length_kb = "???"