Catch OSError and EOFError while reading from gzip stream

This commit is contained in:
Matt Martz 2018-01-02 18:32:03 -06:00
parent 9848481d06
commit c16ffd4ae7
1 changed files with 8 additions and 2 deletions

View File

@ -1041,7 +1041,10 @@ class Speedtest(object):
stream = get_response_stream(uh) stream = get_response_stream(uh)
while 1: while 1:
try:
configxml.append(stream.read(1024)) configxml.append(stream.read(1024))
except (OSError, EOFError):
raise ConfigRetrievalError(get_exception())
if len(configxml[-1]) == 0: if len(configxml[-1]) == 0:
break break
stream.close() stream.close()
@ -1166,7 +1169,10 @@ class Speedtest(object):
serversxml = [] serversxml = []
while 1: while 1:
try:
serversxml.append(stream.read(1024)) serversxml.append(stream.read(1024))
except (OSError, EOFError):
raise ServersRetrievalError(get_exception())
if len(serversxml[-1]) == 0: if len(serversxml[-1]) == 0:
break break