Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

flush stdout/stderr on displayhook call #782

Closed
wants to merge 1 commit into from

2 participants

Min RK Fernando Perez
Min RK
Owner

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
b0f5b76
Fernando Perez
Owner

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

Fernando Perez
Owner

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/displayhook.py
5 IPython/zmq/displayhook.py
View
@@ -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):
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 @@ 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.