Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
0e64fec1
Unverified
Commit
0e64fec1
authored
Oct 21, 2019
by
Thomas Wolf
Committed by
GitHub
Oct 21, 2019
Browse files
Merge pull request #1568 from daemon/patch-1
Fix hanging when loading pretrained models
parents
82f6abd9
a2c8c8ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
transformers/file_utils.py
transformers/file_utils.py
+3
-3
No files found.
transformers/file_utils.py
View file @
0e64fec1
...
@@ -246,7 +246,7 @@ def http_get(url, temp_file, proxies=None):
...
@@ -246,7 +246,7 @@ def http_get(url, temp_file, proxies=None):
progress
.
close
()
progress
.
close
()
def
get_from_cache
(
url
,
cache_dir
=
None
,
force_download
=
False
,
proxies
=
None
):
def
get_from_cache
(
url
,
cache_dir
=
None
,
force_download
=
False
,
proxies
=
None
,
etag_timeout
=
10
):
"""
"""
Given a URL, look for the corresponding dataset in the local cache.
Given a URL, look for the corresponding dataset in the local cache.
If it's not there, download it. Then return the path to the cached file.
If it's not there, download it. Then return the path to the cached file.
...
@@ -266,12 +266,12 @@ def get_from_cache(url, cache_dir=None, force_download=False, proxies=None):
...
@@ -266,12 +266,12 @@ def get_from_cache(url, cache_dir=None, force_download=False, proxies=None):
etag
=
s3_etag
(
url
,
proxies
=
proxies
)
etag
=
s3_etag
(
url
,
proxies
=
proxies
)
else
:
else
:
try
:
try
:
response
=
requests
.
head
(
url
,
allow_redirects
=
True
,
proxies
=
proxies
)
response
=
requests
.
head
(
url
,
allow_redirects
=
True
,
proxies
=
proxies
,
timeout
=
etag_timeout
)
if
response
.
status_code
!=
200
:
if
response
.
status_code
!=
200
:
etag
=
None
etag
=
None
else
:
else
:
etag
=
response
.
headers
.
get
(
"ETag"
)
etag
=
response
.
headers
.
get
(
"ETag"
)
except
EnvironmentError
:
except
(
EnvironmentError
,
requests
.
exceptions
.
Timeout
)
:
etag
=
None
etag
=
None
if
sys
.
version_info
[
0
]
==
2
and
etag
is
not
None
:
if
sys
.
version_info
[
0
]
==
2
and
etag
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment