From ca82bf48f24a3e31fbfaa55f4d5544029a10a98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Speglich?= Date: Fri, 17 Jun 2022 16:36:52 -0300 Subject: [PATCH] ckp: Fix PyRevolve freezing when run in jupyter. --- pyrevolve/tools.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyrevolve/tools.py b/pyrevolve/tools.py index b844794..950b5bf 100644 --- a/pyrevolve/tools.py +++ b/pyrevolve/tools.py @@ -48,12 +48,10 @@ def stop(self): """ Stop capturing the stream data and save the text in `capturedtext`. """ - # Print the escape character to make the readOutput method stop: - self.origstream.write(self.escape_char) + os.write(self.pipe_in, self.escape_char.encode()) # Flush the stream to make sure all our data goes in before # the escape character: - self.origstream.flush() if self.threaded: # wait until the thread finishes so we are sure that # we have until the last character: @@ -74,7 +72,7 @@ def readOutput(self): and save the text in `capturedtext`. """ while True: - char = os.read(self.pipe_out, 1).decode(self.origstream.encoding) + char = os.read(self.pipe_out, 1).decode() if not char or self.escape_char in char: break self.capturedtext += char