|
9 | 9 | from tornado import gen, web
|
10 | 10 | from tornado.ioloop import IOLoop
|
11 | 11 | from tornado.websocket import WebSocketClosedError
|
12 |
| -from traitlets import Bool, Dict, Float, Instance, Int, List, Unicode, default |
| 12 | +from traitlets import Any, Bool, Dict, Float, Instance, Int, List, Unicode, default |
13 | 13 |
|
14 | 14 | try:
|
15 | 15 | from jupyter_client.jsonutil import json_default
|
@@ -89,7 +89,7 @@ class ZMQChannelsWebsocketConnection(BaseKernelWebsocketConnection):
|
89 | 89 | _close_future: Future
|
90 | 90 |
|
91 | 91 | channels = Dict({})
|
92 |
| - kernel_info_channel = Unicode(allow_none=True) |
| 92 | + kernel_info_channel = Any(allow_none=True) |
93 | 93 |
|
94 | 94 | _kernel_info_future = Instance(klass=Future)
|
95 | 95 |
|
@@ -132,7 +132,7 @@ def create_stream(self):
|
132 | 132 | identity = self.session.bsession
|
133 | 133 | for channel in ("iopub", "shell", "control", "stdin"):
|
134 | 134 | meth = getattr(self.kernel_manager, "connect_" + channel)
|
135 |
| - self.channels[channel] = stream = meth(self.kernel_id, identity=identity) |
| 135 | + self.channels[channel] = stream = meth(identity=identity) |
136 | 136 | stream.channel = channel
|
137 | 137 |
|
138 | 138 | def nudge(self):
|
@@ -214,14 +214,6 @@ def on_iopub(msg):
|
214 | 214 | # Nudge the kernel with kernel info requests until we get an IOPub message
|
215 | 215 | def nudge(count):
|
216 | 216 | count += 1
|
217 |
| - |
218 |
| - # NOTE: this close check appears to never be True during on_open, |
219 |
| - # even when the peer has closed the connection |
220 |
| - if self.ws_connection is None or self.ws_connection.is_closing(): |
221 |
| - self.log.debug("Nudge: cancelling on closed websocket: %s", self.kernel_id) |
222 |
| - finish() |
223 |
| - return |
224 |
| - |
225 | 217 | # check for stopped kernel
|
226 | 218 | if self.kernel_id not in self.multi_kernel_manager:
|
227 | 219 | self.log.debug("Nudge: cancelling on stopped kernel: %s", self.kernel_id)
|
@@ -274,8 +266,6 @@ async def _register_session(self):
|
274 | 266 | self._open_sessions[self.session_key] = self
|
275 | 267 |
|
276 | 268 | async def prepare(self):
|
277 |
| - # authenticate first |
278 |
| - super().pre_get() |
279 | 269 | # check session collision:
|
280 | 270 | await self._register_session()
|
281 | 271 | # then request kernel info, waiting up to a certain time before giving up.
|
@@ -525,7 +515,7 @@ def select_subprotocol(self, subprotocols):
|
525 | 515 | def _on_zmq_reply(self, stream, msg_list):
|
526 | 516 | # Sometimes this gets triggered when the on_close method is scheduled in the
|
527 | 517 | # eventloop but hasn't been called.
|
528 |
| - if self.ws_connection is None or stream.closed(): |
| 518 | + if stream.closed(): |
529 | 519 | self.log.warning("zmq message arrived on closed channel")
|
530 | 520 | self.close()
|
531 | 521 | return
|
@@ -554,7 +544,7 @@ def request_kernel_info(self):
|
554 | 544 | # Create a kernel_info channel to query the kernel protocol version.
|
555 | 545 | # This channel will be closed after the kernel_info reply is received.
|
556 | 546 | if self.kernel_info_channel is None:
|
557 |
| - self.kernel_info_channel = self.kernel_manager.connect_shell(self.kernel_id) |
| 547 | + self.kernel_info_channel = self.multi_kernel_manager.connect_shell(self.kernel_id) |
558 | 548 | assert self.kernel_info_channel is not None
|
559 | 549 | self.kernel_info_channel.on_recv(self._handle_kernel_info_reply)
|
560 | 550 | self.session.send(self.kernel_info_channel, "kernel_info_request")
|
|
0 commit comments