From 4f3e93cfaf2e068bf32231feb2c8af66424e6a24 Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Thu, 18 Mar 2021 17:37:45 +0100 Subject: [PATCH] [file_utils] do not gobble certain kinds of requests.ConnectionError (#10235) * do not gobble certain kinds of requests.ConnectionError * Apply review comments Co-authored-by: Lysandre --- examples/legacy/token-classification/run_tf_ner.py | 0 src/transformers/file_utils.py | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 examples/legacy/token-classification/run_tf_ner.py diff --git a/examples/legacy/token-classification/run_tf_ner.py b/examples/legacy/token-classification/run_tf_ner.py old mode 100644 new mode 100755 diff --git a/src/transformers/file_utils.py b/src/transformers/file_utils.py index f2d4a4d248a..2aafdeec645 100644 --- a/src/transformers/file_utils.py +++ b/src/transformers/file_utils.py @@ -1312,8 +1312,12 @@ def get_from_cache( # between the HEAD and the GET (unlikely, but hey). if 300 <= r.status_code <= 399: url_to_download = r.headers["Location"] + except (requests.exceptions.SSLError, requests.exceptions.ProxyError): + # Actually raise for those subclasses of ConnectionError + raise except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): - # etag is already None + # Otherwise, our Internet connection is down. + # etag is None pass filename = url_to_filename(url, etag)