|
21 | 21 |
|
22 | 22 | from jupyter_server.transutils import _i18n
|
23 | 23 |
|
| 24 | +from ..websocket import KernelWebsocketHandler |
24 | 25 | from .abc import KernelWebsocketConnectionABC
|
25 | 26 | from .base import (
|
26 | 27 | BaseKernelWebsocketConnection,
|
@@ -103,7 +104,7 @@ def write_message(self):
|
103 | 104 | # class-level registry of open sessions
|
104 | 105 | # allows checking for conflict on session-id,
|
105 | 106 | # which is used as a zmq identity and must be unique.
|
106 |
| - _open_sessions: dict = {} |
| 107 | + _open_sessions: dict[str, KernelWebsocketHandler] = {} |
107 | 108 | _open_sockets: MutableSet["ZMQChannelsWebsocketConnection"] = weakref.WeakSet()
|
108 | 109 |
|
109 | 110 | _kernel_info_future: Future
|
@@ -391,7 +392,7 @@ def close(self):
|
391 | 392 | def disconnect(self):
|
392 | 393 | self.log.debug("Websocket closed %s", self.session_key)
|
393 | 394 | # unregister myself as an open session (only if it's really me)
|
394 |
| - if self._open_sessions.get(self.session_key) is self: |
| 395 | + if self._open_sessions.get(self.session_key) is self.websocket_handler: |
395 | 396 | self._open_sessions.pop(self.session_key)
|
396 | 397 |
|
397 | 398 | if self.kernel_id in self.multi_kernel_manager:
|
@@ -536,16 +537,6 @@ def _reserialize_reply(self, msg_or_list, channel=None):
|
536 | 537 | else:
|
537 | 538 | return json.dumps(msg, default=json_default)
|
538 | 539 |
|
539 |
| - def select_subprotocol(self, subprotocols): |
540 |
| - preferred_protocol = self.kernel_ws_protocol |
541 |
| - if preferred_protocol is None: |
542 |
| - preferred_protocol = "v1.kernel.websocket.jupyter.org" |
543 |
| - elif preferred_protocol == "": |
544 |
| - preferred_protocol = None |
545 |
| - selected_subprotocol = preferred_protocol if preferred_protocol in subprotocols else None |
546 |
| - # None is the default, "legacy" protocol |
547 |
| - return selected_subprotocol |
548 |
| - |
549 | 540 | def _on_zmq_reply(self, stream, msg_list):
|
550 | 541 | # Sometimes this gets triggered when the on_close method is scheduled in the
|
551 | 542 | # eventloop but hasn't been called.
|
|
0 commit comments