Skip to content

Commit cd254f5

Browse files
authored
Merge pull request #258 from toabctl/fix-incomplete-read
Workaround IncompleteRead when downloading src
2 parents 2324066 + e73c7fe commit cd254f5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

nodeenv.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434
# noinspection PyCompatibility
3535
import urllib2
3636
iteritems = operator.methodcaller('iteritems')
37+
import httplib
38+
IncompleteRead = httplib.IncompleteRead
3739
except ImportError: # pragma: no cover (py3 only)
3840
from configparser import ConfigParser
3941
# noinspection PyUnresolvedReferences
4042
import urllib.request as urllib2
4143
iteritems = operator.methodcaller('items')
44+
import http
45+
IncompleteRead = http.client.IncompleteRead
4246

4347
from pkg_resources import parse_version
4448

@@ -545,7 +549,12 @@ def download_node_src(node_url, src_dir, opt):
545549
Download source code
546550
"""
547551
logger.info('.', extra=dict(continued=True))
548-
dl_contents = io.BytesIO(urlopen(node_url).read())
552+
try:
553+
dl_contents = io.BytesIO(urlopen(node_url).read())
554+
except IncompleteRead as e:
555+
logger.warning('Incomplete read while reading'
556+
'from {}'.format(node_url))
557+
dl_contents = e.partial
549558
logger.info('.', extra=dict(continued=True))
550559

551560
if is_WIN or is_CYGWIN:

0 commit comments

Comments
 (0)