From 00a45d7cba49536ecb14aa83960b33e682deed2e Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 18 Jan 2024 17:16:00 +0100 Subject: [PATCH] Patch HoloViews client comm to ensure server comm is initialized (#6234) --- CHANGELOG.md | 3 ++- doc/about/releases.md | 3 ++- panel/io/notebook.py | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 865b771030..4bbad7847b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,8 @@ This patch release focuses on a number of fixes and minor enhancements for the c - Fix pyodide loading message styling issues ([#6194](https://github.com/holoviz/panel/pull/6194)) - More complete patch for the `TextEditor` to support being rendered in the Shadow DOM ([#6222](https://github.com/holoviz/panel/pull/6222)) - Add guard to `Tabulator` ensuring that it does not error when it is not rendered ([#6223](https://github.com/holoviz/panel/pull/6223)) -- Fix race conditions when instantiating Comm in Jupyter causing notifications to break ([#6229](https://github.com/holoviz/panel/pull/6229)) +- Fix race conditions when instantiating Comm in Jupyter causing notifications to break ([#6229](https://github.com/holoviz/panel/pull/6229), [#6234](https://github.com/holoviz/panel/pull/6234)) +- Handle duplicate attempts at refreshing auth tokens ([#6233](https://github.com/holoviz/panel/pull/6233)) ### Compatibility & Security diff --git a/doc/about/releases.md b/doc/about/releases.md index d6af9fc7e0..b608f3b4e0 100644 --- a/doc/about/releases.md +++ b/doc/about/releases.md @@ -36,7 +36,8 @@ This patch release focuses on a number of fixes and minor enhancements for the c - Fix pyodide loading message styling issues ([#6194](https://github.com/holoviz/panel/pull/6194)) - More complete patch for the `TextEditor` to support being rendered in the Shadow DOM ([#6222](https://github.com/holoviz/panel/pull/6222)) - Add guard to `Tabulator` ensuring that it does not error when it is not rendered ([#6223](https://github.com/holoviz/panel/pull/6223)) -- Fix race conditions when instantiating Comm in Jupyter causing notifications to break ([#6229](https://github.com/holoviz/panel/pull/6229)) +- Fix race conditions when instantiating Comm in Jupyter causing notifications to break ([#6229](https://github.com/holoviz/panel/pull/6229), [#6234](https://github.com/holoviz/panel/pull/6234)) +- Handle duplicate attempts at refreshing auth tokens ([#6233](https://github.com/holoviz/panel/pull/6233)) ### Compatibility & Security diff --git a/panel/io/notebook.py b/panel/io/notebook.py index 61c12766c3..536154d824 100644 --- a/panel/io/notebook.py +++ b/panel/io/notebook.py @@ -241,6 +241,13 @@ def render_mimebundle( Displays bokeh output inside a notebook using the PyViz display and comms machinery. """ + # WARNING: Patches the client comm created by some external library + # e.g. HoloViews, with an on_open handler that will initialize + # the server comm. + if manager and manager.client_comm_id in _JupyterCommManager._comms: + client_comm = _JupyterCommManager._comms[manager.client_comm_id] + if not client_comm._on_open: + client_comm._on_open = lambda _: comm.init() if not isinstance(model, Model): raise ValueError('Can only render bokeh LayoutDOM models') add_to_doc(model, doc, True)