Merge pull request #165 from vbanos/stderr-stdout-exception-handling

Improve exception handling when reading STDIN/STDERR
This commit is contained in:
Noah Levitt 2019-09-24 12:03:06 -07:00 committed by GitHub
commit eb30ba0c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,10 +250,16 @@ class Chrome:
# XXX select doesn't work on windows
def readline_nonblock(f):
buf = b''
while not self._shutdown.is_set() and (
try:
while not self._shutdown.is_set() and (
len(buf) == 0 or buf[-1] != 0xa) and select.select(
[f],[],[],0.5)[0]:
buf += f.read(1)
buf += f.read(1)
except (ValueError, OSError):
# When the chrome process crashes, stdout & stderr are closed
# and trying to read from them raises these exceptions. We just
# stop reading and return current `buf`.
pass
return buf
try: