-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
kernelapp: Allow preserving stdout and stderr in kernel #315
Conversation
cc @Carreau |
ipykernel/kernelapp.py
Outdated
sys.stdout = outstream_factory(self.session, self.iopub_thread, u'stdout') | ||
sys.stdout = outstream_factory(self.session, self.iopub_thread, | ||
u'stdout', | ||
echo=sys.__stdout__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be the default behavior. The default stdout/stderr should only be redirected by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@minrk I figured as much. How do you think this would be best configured. A property on the kernel class or a property on the kernel app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to be controlled by a quiet
attribute. Similar to no_stdout.
ipykernel/iostream.py
Outdated
try: | ||
self.echo.write(string) | ||
except OSError as e: | ||
if self.echo != sys.__stderr__: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use is not
for this check
6dcfe77
to
7f9e5a5
Compare
Thanks! |
I'd like to be able to have access to stdout/stderr the normal way so I threw together the following patch.
I imagine others might want a way to turn this off but I figured I'd share and we can refine further if others are interested.