Skip to content
This repository

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 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 September 12, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 12, 2011
Min RK flush stdout/stderr on displayhook
This helps stream output arrive before pyout.

closes gh-780
b0f5b76
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 0 deletions. Show diff stats Hide diff stats

  1. 5  IPython/zmq/displayhook.py
5  IPython/zmq/displayhook.py
... ...
@@ -1,4 +1,5 @@
1 1
 import __builtin__
  2
+import sys
2 3
 from base64 import encodestring
3 4
 
4 5
 from IPython.core.displayhook import DisplayHook
@@ -20,6 +21,8 @@ def __call__(self, obj):
20 21
             return
21 22
 
22 23
         __builtin__._ = obj
  24
+        sys.stdout.flush()
  25
+        sys.stderr.flush()
23 26
         msg = self.session.send(self.pub_socket, u'pyout', {u'data':repr(obj)},
24 27
                                parent=self.parent_header, ident=self.topic)
25 28
 
@@ -63,6 +66,8 @@ def write_format_data(self, format_dict):
63 66
 
64 67
     def finish_displayhook(self):
65 68
         """Finish up all displayhook activities."""
  69
+        sys.stdout.flush()
  70
+        sys.stderr.flush()
66 71
         self.session.send(self.pub_socket, self.msg)
67 72
         self.msg = None
68 73
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.