mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-07-26 16:25:43 -04:00
Merge pull request #165 from vbanos/stderr-stdout-exception-handling
Improve exception handling when reading STDIN/STDERR
This commit is contained in:
commit
eb30ba0c33
1 changed files with 8 additions and 2 deletions
|
@ -250,10 +250,16 @@ class Chrome:
|
||||||
# XXX select doesn't work on windows
|
# XXX select doesn't work on windows
|
||||||
def readline_nonblock(f):
|
def readline_nonblock(f):
|
||||||
buf = b''
|
buf = b''
|
||||||
|
try:
|
||||||
while not self._shutdown.is_set() and (
|
while not self._shutdown.is_set() and (
|
||||||
len(buf) == 0 or buf[-1] != 0xa) and select.select(
|
len(buf) == 0 or buf[-1] != 0xa) and select.select(
|
||||||
[f],[],[],0.5)[0]:
|
[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
|
return buf
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue