##// END OF EJS Templates
Add missing flush of output streams on execute
Fernando Perez -
Show More
@@ -4,6 +4,8 b' from cStringIO import StringIO'
4 4
5 5 from session import extract_header, Message
6 6
7 from IPython.utils import io
8
7 9 #-----------------------------------------------------------------------------
8 10 # Stream classes
9 11 #-----------------------------------------------------------------------------
@@ -28,6 +30,7 b' class OutStream(object):'
28 30 self.pub_socket = None
29 31
30 32 def flush(self):
33 #io.rprint('>>>flushing output buffer: %s<<<' % self.name) # dbg
31 34 if self.pub_socket is None:
32 35 raise ValueError(u'I/O operation on closed file')
33 36 else:
@@ -36,7 +39,7 b' class OutStream(object):'
36 39 content = {u'name':self.name, u'data':data}
37 40 msg = self.session.msg(u'stream', content=content,
38 41 parent=self.parent_header)
39 print>>sys.__stdout__, Message(msg)
42 io.raw_print(msg)
40 43 self.pub_socket.send_json(msg)
41 44
42 45 self._buffer.close()
@@ -74,4 +77,4 b' class OutStream(object):'
74 77
75 78 def _new_buffer(self):
76 79 self._buffer = StringIO()
77 self._start = -1 No newline at end of file
80 self._start = -1
@@ -195,6 +195,15 b' class Kernel(Configurable):'
195 195 # Send the reply.
196 196 reply_msg = self.session.msg(u'execute_reply', reply_content, parent)
197 197 io.raw_print(reply_msg)
198
199 # Flush output before sending the reply.
200 sys.stdout.flush()
201 sys.stderr.flush()
202 # FIXME: on rare occasions, the flush doesn't seem to make it to the
203 # clients... This seems to mitigate the problem, but we definitely need
204 # to better understand what's going on.
205 time.sleep(0.05)
206
198 207 self.reply_socket.send(ident, zmq.SNDMORE)
199 208 self.reply_socket.send_json(reply_msg)
200 209 if reply_msg['content']['status'] == u'error':
General Comments 0
You need to be logged in to leave comments. Login now