Skip to content

Commit

Permalink
Start kernel client channels when reusing already running in-process …
Browse files Browse the repository at this point in the history
…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).
  • Loading branch information
dalthviz authored Dec 6, 2024
1 parent 463f828 commit 2e9ca54
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions napari_console/qt_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e9ca54

Please # to comment.