From 2e9ca54936d33a5282107c3167252aac23c1233f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= <16781833+dalthviz@users.noreply.github.com> Date: Thu, 5 Dec 2024 22:10:20 -0500 Subject: [PATCH] Start kernel client channels when reusing already running in-process kernel (#39) Closes napari/napari#7413 This PR allows multiple napari viewers in the same session to each have a console, with the consoles having linked histories and kernel (active variables). --- napari_console/qt_console.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/napari_console/qt_console.py b/napari_console/qt_console.py index de06be5..a55fb50 100644 --- a/napari_console/qt_console.py +++ b/napari_console/qt_console.py @@ -129,10 +129,11 @@ def __init__(self, viewer: 'napari.viewer.Viewer', *, min_depth: int = 1, style_ elif type(shell) == InProcessInteractiveShell: # If there is an existing running InProcessInteractiveShell # it is likely because multiple viewers have been launched from - # the same process. In that case create a new kernel. - # Connect existing kernel + # the same process. In that case create a new kernel manager but + # connect to the existing kernel. kernel_manager = QtInProcessKernelManager(kernel=shell.kernel) kernel_client = kernel_manager.client() + kernel_client.start_channels() self.kernel_manager = kernel_manager self.kernel_client = kernel_client