Skip to content

Commit

Permalink
Bugfix: binary stdout/stderr handling (#1129)
Browse files Browse the repository at this point in the history
Co-authored-by: Ariel Eizenberg <ariel.eizenberg@pagaya.com>
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
  • Loading branch information
3 people authored Jun 29, 2023
1 parent a18f007 commit 0c1db09
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ipykernel/iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
MASTER = 0
CHILD = 1

PIPE_BUFFER_SIZE = 1000

# -----------------------------------------------------------------------------
# IO classes
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -367,11 +369,11 @@ def _watch_pipe_fd(self):
"""

try:
bts = os.read(self._fid, 1000)
bts = os.read(self._fid, PIPE_BUFFER_SIZE)
while bts and self._should_watch:
self.write(bts.decode())
self.write(bts.decode(errors='replace'))
os.write(self._original_stdstream_copy, bts)
bts = os.read(self._fid, 1000)
bts = os.read(self._fid, PIPE_BUFFER_SIZE)
except Exception:
self._exc = sys.exc_info()

Expand Down

0 comments on commit 0c1db09

Please sign in to comment.