Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ckp: Fix PyRevolve freezing when run in jupyter. #57

Merged
merged 1 commit into from
Jul 4, 2022
Merged
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
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