##// END OF EJS Templates
Added a flush method to the SubSocketChannel. The Qt console frontend now uses this method to ensure that output has been processed before it writes a new prompt.
epatters -
Show More
@@ -267,6 +267,10 b' class FrontendWidget(HistoryConsoleWidget):'
267 self.appendPlainText(omsg['content']['data'])
267 self.appendPlainText(omsg['content']['data'])
268
268
269 def _handle_execute_reply(self, rep):
269 def _handle_execute_reply(self, rep):
270 # Make sure that all output from the SUB channel has been processed
271 # before writing a new prompt.
272 self.kernel_manager.sub_channel.flush()
273
270 content = rep['content']
274 content = rep['content']
271 status = content['status']
275 status = content['status']
272 if status == 'error':
276 if status == 'error':
@@ -47,6 +47,12 b' class QtSubSocketChannel(SubSocketChannel, QtCore.QObject):'
47 elif msg_type in ('pyerr', 'stderr'):
47 elif msg_type in ('pyerr', 'stderr'):
48 self.error_received.emit(msg)
48 self.error_received.emit(msg)
49
49
50 def flush(self):
51 """ Reimplemented to ensure that signals are dispatched immediately.
52 """
53 super(QtSubSocketChannel, self).flush()
54 QtCore.QCoreApplication.instance().processEvents()
55
50
56
51 class QtXReqSocketChannel(XReqSocketChannel, QtCore.QObject):
57 class QtXReqSocketChannel(XReqSocketChannel, QtCore.QObject):
52
58
@@ -7,6 +7,7 b' TODO: Create logger to handle debugging and console messages.'
7 # Standard library imports.
7 # Standard library imports.
8 from Queue import Queue, Empty
8 from Queue import Queue, Empty
9 from threading import Thread
9 from threading import Thread
10 import time
10 import traceback
11 import traceback
11
12
12 # System library imports.
13 # System library imports.
@@ -107,8 +108,24 b' class SubSocketChannel(ZmqSocketChannel):'
107 self.handlers[msg_type] = callback
108 self.handlers[msg_type] = callback
108
109
109 def remove_handler(self, msg_type):
110 def remove_handler(self, msg_type):
111 """Remove the callback for msg type."""
110 self.handlers.pop(msg_type, None)
112 self.handlers.pop(msg_type, None)
111
113
114 def flush(self):
115 """Immediately processes all pending messages on the SUB channel. This
116 method is thread safe.
117 """
118 self._flushed = False
119 self.ioloop.add_callback(self._flush)
120 while not self._flushed:
121 time.sleep(0)
122
123 def _flush(self):
124 """Called in this thread by the IOLoop to indicate that all events have
125 been processed.
126 """
127 self._flushed = True
128
112
129
113 class XReqSocketChannel(ZmqSocketChannel):
130 class XReqSocketChannel(ZmqSocketChannel):
114
131
General Comments 0
You need to be logged in to leave comments. Login now