Skip to content

Commit

Permalink
Merge pull request #258 from toabctl/fix-incomplete-read
Browse files Browse the repository at this point in the history
Workaround IncompleteRead when downloading src
  • Loading branch information
ekalinin authored May 25, 2020
2 parents 2324066 + e73c7fe commit cd254f5
Showing 1 changed file with 10 additions and 1 deletion.
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

0 comments on commit cd254f5

Please sign in to comment.