[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 <lysandre.debut@reseau.eseo.fr>
This commit is contained in:
Julien Chaumond 2021-03-18 17:37:45 +01:00 committed by GitHub
parent ce9724e1bd
commit 4f3e93cfaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

0
examples/legacy/token-classification/run_tf_ner.py Normal file → Executable file
View File

View File

@ -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)