Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


flush stdout/stderr on displayhook call #782

wants to merge 1 commit into from

2 participants

Min RK Fernando Perez
Min RK

This makes the displayhook invocation a sync point for streams, helping ensure that text printed prior to return values will arrive prior to the return output.

should fix #780

Min RK minrk flush stdout/stderr on displayhook
This helps stream output arrive before pyout.

closes gh-780
Fernando Perez

Great, thanks! I'd been meaning to do this for a while. Merging now.

Fernando Perez

Merged, I rebased to avoid the merge loop for just one commit. Closing here.

Fernando Perez fperez closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 12, 2011
  1. Min RK

    flush stdout/stderr on displayhook

    minrk authored
    This helps stream output arrive before pyout.
    closes gh-780
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 IPython/zmq/
5 IPython/zmq/
@@ -1,4 +1,5 @@
import __builtin__
+import sys
from base64 import encodestring
from IPython.core.displayhook import DisplayHook
@@ -20,6 +21,8 @@ def __call__(self, obj):
__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 @@ def write_format_data(self, format_dict):
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
Something went wrong with that request. Please try again.