Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ipykernel/iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def __init__(
self._buffer = StringIO()
self.echo = None
self._isatty = bool(isatty)
self._should_watch = False

if (
watchfd
Expand Down Expand Up @@ -449,7 +450,7 @@ def set_parent(self, parent):

def close(self):
"""Close the stream."""
if sys.platform.startswith("linux") or sys.platform.startswith("darwin"):
if self._should_watch:
self._should_watch = False
self.watch_fd_thread.join()
if self._exc:
Expand Down
3 changes: 3 additions & 0 deletions ipykernel/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def test_outstream():
stream = OutStream(session, pub, "stdout")
stream = OutStream(session, thread, "stdout", pipe=object())

stream = OutStream(session, thread, "stdout", watchfd=False)
stream.close()

stream = OutStream(session, thread, "stdout", isatty=True, echo=io.StringIO())
with pytest.raises(io.UnsupportedOperation):
stream.fileno()
Expand Down