Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Workaround IncompleteRead when downloading src #258

Merged
merged 1 commit into from
May 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@
# noinspection PyCompatibility
import urllib2
iteritems = operator.methodcaller('iteritems')
import httplib
IncompleteRead = httplib.IncompleteRead
except ImportError: # pragma: no cover (py3 only)
from configparser import ConfigParser
# noinspection PyUnresolvedReferences
import urllib.request as urllib2
iteritems = operator.methodcaller('items')
import http
IncompleteRead = http.client.IncompleteRead

from pkg_resources import parse_version

Expand Down Expand Up @@ -545,7 +549,12 @@ def download_node_src(node_url, src_dir, opt):
Download source code
"""
logger.info('.', extra=dict(continued=True))
dl_contents = io.BytesIO(urlopen(node_url).read())
try:
dl_contents = io.BytesIO(urlopen(node_url).read())
except IncompleteRead as e:
logger.warning('Incomplete read while reading'
'from {}'.format(node_url))
dl_contents = e.partial
logger.info('.', extra=dict(continued=True))

if is_WIN or is_CYGWIN:
Expand Down