From a677855e861d68533e30018d33bacc4d65a7d5a3 2011-09-12 18:40:12 From: MinRK Date: 2011-09-12 18:40:12 Subject: [PATCH] flush stdout/stderr on displayhook This helps stream output arrive before pyout. closes gh-780 --- diff --git a/IPython/zmq/displayhook.py b/IPython/zmq/displayhook.py index 2cf5ff5..d9f4251 100644 --- a/IPython/zmq/displayhook.py +++ b/IPython/zmq/displayhook.py @@ -1,4 +1,5 @@ import __builtin__ +import sys from base64 import encodestring from IPython.core.displayhook import DisplayHook @@ -20,6 +21,8 @@ class ZMQDisplayHook(object): return __builtin__._ = obj + sys.stdout.flush() + sys.stderr.flush() msg = self.session.send(self.pub_socket, u'pyout', {u'data':repr(obj)}, parent=self.parent_header, ident=self.topic) @@ -63,6 +66,8 @@ class ZMQShellDisplayHook(DisplayHook): def finish_displayhook(self): """Finish up all displayhook activities.""" + sys.stdout.flush() + sys.stderr.flush() self.session.send(self.pub_socket, self.msg) self.msg = None