mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Catch failures reading data from terminated subprocesses
This commit is contained in:
parent
d729dfbbe2
commit
79c0712752
@ -382,9 +382,21 @@ class StreamCapturer(Thread):
|
||||
continue
|
||||
|
||||
ready = select(streams, [], [], 0.5)[0]
|
||||
dead = []
|
||||
with self.buffer_lock:
|
||||
for fd in ready:
|
||||
self.buffer.write(os.read(fd, 1024))
|
||||
try:
|
||||
self.buffer.write(os.read(fd, 1024))
|
||||
except OSError as e:
|
||||
import errno
|
||||
if e.errno == errno.EBADF:
|
||||
dead.append(fd)
|
||||
else:
|
||||
raise
|
||||
|
||||
with self.streams_lock:
|
||||
for fd in dead:
|
||||
self.streams.remove(fd)
|
||||
|
||||
def add_stream(self, fd):
|
||||
with self.streams_lock:
|
||||
|
Loading…
Reference in New Issue
Block a user