Skip to content

Commit

Permalink
Add kernel_ws_protocol configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Jan 26, 2022
1 parent e9bc830 commit ecda217
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
11 changes: 6 additions & 5 deletions jupyter_server/base/zmqhandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,12 @@ def _reserialize_reply(self, msg_or_list, channel=None):
return cast_unicode(smsg)

def select_subprotocol(self, subprotocols):
selected_subprotocol = (
"v1.kernel.websocket.jupyter.org"
if "v1.kernel.websocket.jupyter.org" in subprotocols
else None
)
preferred_protocol = self.settings.get("kernel_ws_protocol")
if preferred_protocol is None:
preferred_protocol = "v1.kernel.websocket.jupyter.org"
elif preferred_protocol == "":
preferred_protocol = None
selected_subprotocol = preferred_protocol if preferred_protocol in subprotocols else None
# None is the default, "legacy" protocol
return selected_subprotocol

Expand Down
15 changes: 15 additions & 0 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def init_settings(
"no_cache_paths": [url_path_join(base_url, "static", "custom")],
},
version_hash=version_hash,
# kernel message protocol over websoclet
kernel_ws_protocol=jupyter_app.kernel_ws_protocol,
# rate limits
limit_rate=jupyter_app.limit_rate,
iopub_msg_rate_limit=jupyter_app.iopub_msg_rate_limit,
Expand Down Expand Up @@ -1613,6 +1615,19 @@ def _update_server_extensions(self, change):
help=_i18n("Reraise exceptions encountered loading server extensions?"),
)

kernel_ws_protocol = Unicode(
None,
allow_none=True,
config=True,
help=_i18n(
"Preferred kernel message protocol over websocket to use (default: None). "
"If an empty string is passed, select the legacy protocol. If None, "
"the selected protocol will depend on what the front-end supports "
"(usually the most recent protocol supported by the back-end and the "
"front-end)."
),
)

limit_rate = Bool(
False,
config=True,
Expand Down

0 comments on commit ecda217

Please sign in to comment.