##// END OF EJS Templates
Get rid of Qt Shell and Stdin channels
Thomas Kluyver -
Show More
@@ -103,6 +103,7 b' class QtZMQSocketChannel(SuperQObject, Thread):'
103 self.socket = socket
103 self.socket = socket
104 self.session = session
104 self.session = session
105 atexit.register(self._notice_exit)
105 atexit.register(self._notice_exit)
106 self.ioloop = ioloop.IOLoop()
106
107
107 def _notice_exit(self):
108 def _notice_exit(self):
108 self._exiting = True
109 self._exiting = True
@@ -131,6 +132,12 b' class QtZMQSocketChannel(SuperQObject, Thread):'
131 super(QtZMQSocketChannel, self).start()
132 super(QtZMQSocketChannel, self).start()
132 self.started.emit()
133 self.started.emit()
133
134
135 def run(self):
136 """The thread's main activity. Call start() instead."""
137 self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
138 self.stream.on_recv(self._handle_recv)
139 self._run_loop()
140
134 def stop(self):
141 def stop(self):
135 """Stop the channel's event loop and join its thread.
142 """Stop the channel's event loop and join its thread.
136
143
@@ -200,53 +207,12 b' class QtZMQSocketChannel(SuperQObject, Thread):'
200 self.message_received.emit(msg)
207 self.message_received.emit(msg)
201
208
202
209
203 class QtShellChannel(QtZMQSocketChannel):
204 """The shell channel for issuing request/replies to the kernel."""
205
206 def __init__(self, socket, session):
207 super(QtShellChannel, self).__init__(socket, session)
208 self.ioloop = ioloop.IOLoop()
209
210 def run(self):
211 """The thread's main activity. Call start() instead."""
212 self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
213 self.stream.on_recv(self._handle_recv)
214 self._run_loop()
215
216 def call_handlers(self, msg):
217 super(QtShellChannel, self).call_handlers(msg)
218
219 # Catch kernel_info_reply for message spec adaptation
220 msg_type = msg['header']['msg_type']
221 if msg_type == 'kernel_info_reply':
222 self._handle_kernel_info_reply(msg)
223
224 def _handle_kernel_info_reply(self, msg):
225 """handle kernel info reply
226
227 sets protocol adaptation version
228 """
229 adapt_version = int(msg['content']['protocol_version'].split('.')[0])
230 if adapt_version != major_protocol_version:
231 self.session.adapt_version = adapt_version
232
233
234 class QtIOPubChannel(QtZMQSocketChannel):
210 class QtIOPubChannel(QtZMQSocketChannel):
235 """The iopub channel which listens for messages that the kernel publishes.
211 """The iopub channel which listens for messages that the kernel publishes.
236
212
237 This channel is where all output is published to frontends.
213 This channel is where all output is published to frontends.
238 """
214 """
239
215
240 def __init__(self, socket, session):
241 super(QtIOPubChannel, self).__init__(socket, session)
242 self.ioloop = ioloop.IOLoop()
243
244 def run(self):
245 """The thread's main activity. Call start() instead."""
246 self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
247 self.stream.on_recv(self._handle_recv)
248 self._run_loop()
249
250 def flush(self, timeout=1.0):
216 def flush(self, timeout=1.0):
251 """Immediately processes all pending messages on the iopub channel.
217 """Immediately processes all pending messages on the iopub channel.
252
218
@@ -276,27 +242,7 b' class QtIOPubChannel(QtZMQSocketChannel):'
276 self.stream.flush()
242 self.stream.flush()
277 self._flushed = True
243 self._flushed = True
278
244
279
280 class QtStdInChannel(QtZMQSocketChannel):
281 """The stdin channel to handle raw_input requests that the kernel makes."""
282
283 msg_queue = None
284 proxy_methods = ['input']
285
286 def __init__(self, socket, session):
287 super(QtStdInChannel, self).__init__(socket, session)
288 self.ioloop = ioloop.IOLoop()
289
290 def run(self):
291 """The thread's main activity. Call start() instead."""
292 self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
293 self.stream.on_recv(self._handle_recv)
294 self._run_loop()
295
296
297 ShellChannelABC.register(QtShellChannel)
298 IOPubChannelABC.register(QtIOPubChannel)
245 IOPubChannelABC.register(QtIOPubChannel)
299 StdInChannelABC.register(QtStdInChannel)
300
246
301
247
302 class QtKernelClient(QtKernelClientMixin, KernelClient):
248 class QtKernelClient(QtKernelClientMixin, KernelClient):
@@ -313,6 +259,6 b' class QtKernelClient(QtKernelClientMixin, KernelClient):'
313 self.shell_channel.message_received.disconnect(self._check_kernel_info_reply)
259 self.shell_channel.message_received.disconnect(self._check_kernel_info_reply)
314
260
315 iopub_channel_class = Type(QtIOPubChannel)
261 iopub_channel_class = Type(QtIOPubChannel)
316 shell_channel_class = Type(QtShellChannel)
262 shell_channel_class = Type(QtZMQSocketChannel)
317 stdin_channel_class = Type(QtStdInChannel)
263 stdin_channel_class = Type(QtZMQSocketChannel)
318 hb_channel_class = Type(QtHBChannel)
264 hb_channel_class = Type(QtHBChannel)
General Comments 0
You need to be logged in to leave comments. Login now