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

kernelapp: Allow preserving stdout and stderr in kernel #315

Merged
merged 1 commit into from Apr 13, 2018

Conversation

cHYzZQo
Copy link
Contributor

@cHYzZQo cHYzZQo commented Mar 13, 2018

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.

@rgbkrk
Copy link
Member

rgbkrk commented Mar 28, 2018

cc @Carreau

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__)
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

try:
self.echo.write(string)
except OSError as e:
if self.echo != sys.__stderr__:
Copy link
Member

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

@cHYzZQo
Copy link
Contributor Author

cHYzZQo commented Apr 12, 2018

@rgbkrk @minrk some combination of rebasing and updated dep versions fixed the tests. This is ready for another look.

@minrk minrk changed the title kernelapp: Preserve stdout and stderr in kernel kernelapp: Allow preserving stdout and stderr in kernel Apr 13, 2018
@minrk minrk merged commit bf6b278 into ipython:master Apr 13, 2018
@minrk
Copy link
Member

minrk commented Apr 13, 2018

Thanks!

@blink1073 blink1073 added this to the 4.9 milestone Aug 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants