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

flush stdout/stderr at the end of kernel init #1023

Merged
merged 3 commits into from Nov 24, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions IPython/frontend/html/notebook/static/js/notebook.js
Expand Up @@ -726,6 +726,11 @@ var IPython = (function (IPython) {
// console.log(reply);
var msg_type = reply.header.msg_type;
var cell = this.cell_for_msg(reply.parent_header.msg_id);
if (!cell){
// message not from this notebook
console.log("Received IOPub message not caused by one of my cells");
return;
}
var output_types = ['stream','display_data','pyout','pyerr'];
if (output_types.indexOf(msg_type) >= 0) {
this.handle_output(cell, msg_type, content);
Expand Down
7 changes: 6 additions & 1 deletion IPython/frontend/qt/base_frontend_mixin.py
Expand Up @@ -106,4 +106,9 @@ def _is_from_this_session(self, msg):
from this frontend.
"""
session = self._kernel_manager.session.session
return msg['parent_header']['session'] == session
parent = msg['parent_header']
if not parent:
# if the message has no parent, assume it is meant for all frontends
return True
else:
return parent.get('session') == session
3 changes: 3 additions & 0 deletions IPython/lib/pylabtools.py
Expand Up @@ -19,6 +19,7 @@
# Imports
#-----------------------------------------------------------------------------

import sys
from io import BytesIO

from IPython.utils.decorators import flag_calls
Expand Down Expand Up @@ -317,6 +318,8 @@ def pylab_activate(user_ns, gui=None, import_all=True, shell=None):
print """
Welcome to pylab, a matplotlib-based Python environment [backend: %s].
For more information, type 'help(pylab)'.""" % backend
# flush stdout, just to be safe
sys.stdout.flush()

return gui

4 changes: 4 additions & 0 deletions IPython/zmq/kernelapp.py
Expand Up @@ -287,6 +287,10 @@ def initialize(self, argv=None):
self.write_connection_file()
self.init_io()
self.init_kernel()
# flush stdout/stderr, so that anything written to these streams during
# initialization do not get associated with the first execution request
sys.stdout.flush()
sys.stderr.flush()

def start(self):
self.heartbeat.start()
Expand Down