Skip to content

Commit

Permalink
Merge pull request #57 from speglich/jupyter-integration
Browse files Browse the repository at this point in the history
ckp: Fix PyRevolve freezing when run in jupyter.
  • Loading branch information
navjotk authored Jul 4, 2022
2 parents d0e7e60 + ca82bf4 commit 7f1d4ab
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pyrevolve/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit 7f1d4ab

Please sign in to comment.