Skip to content

Commit

Permalink
flush stdout/stderr on displayhook
Browse files Browse the repository at this point in the history
This helps stream output arrive before pyout.

closes ipythongh-780
  • Loading branch information
minrk committed Sep 12, 2011
1 parent 17494a1 commit b0f5b76
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions IPython/zmq/displayhook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import __builtin__
import sys
from base64 import encodestring

from IPython.core.displayhook import DisplayHook
Expand All @@ -20,6 +21,8 @@ def __call__(self, obj):
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)

Expand Down Expand Up @@ -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

0 comments on commit b0f5b76

Please sign in to comment.