Show More
@@ -4,6 +4,8 b' from cStringIO import StringIO' | |||||
4 |
|
4 | |||
5 | from session import extract_header, Message |
|
5 | from session import extract_header, Message | |
6 |
|
6 | |||
|
7 | from IPython.utils import io | |||
|
8 | ||||
7 | #----------------------------------------------------------------------------- |
|
9 | #----------------------------------------------------------------------------- | |
8 | # Stream classes |
|
10 | # Stream classes | |
9 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
@@ -28,6 +30,7 b' class OutStream(object):' | |||||
28 | self.pub_socket = None |
|
30 | self.pub_socket = None | |
29 |
|
31 | |||
30 | def flush(self): |
|
32 | def flush(self): | |
|
33 | #io.rprint('>>>flushing output buffer: %s<<<' % self.name) # dbg | |||
31 | if self.pub_socket is None: |
|
34 | if self.pub_socket is None: | |
32 | raise ValueError(u'I/O operation on closed file') |
|
35 | raise ValueError(u'I/O operation on closed file') | |
33 | else: |
|
36 | else: | |
@@ -36,7 +39,7 b' class OutStream(object):' | |||||
36 | content = {u'name':self.name, u'data':data} |
|
39 | content = {u'name':self.name, u'data':data} | |
37 | msg = self.session.msg(u'stream', content=content, |
|
40 | msg = self.session.msg(u'stream', content=content, | |
38 | parent=self.parent_header) |
|
41 | parent=self.parent_header) | |
39 |
|
|
42 | io.raw_print(msg) | |
40 | self.pub_socket.send_json(msg) |
|
43 | self.pub_socket.send_json(msg) | |
41 |
|
44 | |||
42 | self._buffer.close() |
|
45 | self._buffer.close() | |
@@ -74,4 +77,4 b' class OutStream(object):' | |||||
74 |
|
77 | |||
75 | def _new_buffer(self): |
|
78 | def _new_buffer(self): | |
76 | self._buffer = StringIO() |
|
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 | # Send the reply. |
|
195 | # Send the reply. | |
196 | reply_msg = self.session.msg(u'execute_reply', reply_content, parent) |
|
196 | reply_msg = self.session.msg(u'execute_reply', reply_content, parent) | |
197 | io.raw_print(reply_msg) |
|
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 | self.reply_socket.send(ident, zmq.SNDMORE) |
|
207 | self.reply_socket.send(ident, zmq.SNDMORE) | |
199 | self.reply_socket.send_json(reply_msg) |
|
208 | self.reply_socket.send_json(reply_msg) | |
200 | if reply_msg['content']['status'] == u'error': |
|
209 | if reply_msg['content']['status'] == u'error': |
General Comments 0
You need to be logged in to leave comments.
Login now