diff --git a/IPython/lib/pylabtools.py b/IPython/lib/pylabtools.py index c64cbf3..3fb9444 100644 --- a/IPython/lib/pylabtools.py +++ b/IPython/lib/pylabtools.py @@ -19,6 +19,7 @@ Authors # Imports #----------------------------------------------------------------------------- +import sys from io import BytesIO from IPython.utils.decorators import flag_calls @@ -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 diff --git a/IPython/zmq/kernelapp.py b/IPython/zmq/kernelapp.py index 9edf871..a8d105e 100644 --- a/IPython/zmq/kernelapp.py +++ b/IPython/zmq/kernelapp.py @@ -287,6 +287,10 @@ class KernelApp(BaseIPythonApplication): 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()