-
Notifications
You must be signed in to change notification settings - Fork 953
Open
Description
When I re-execute a cell that creates an ipywidget (e.g., IntSlider), the old comm is not closed and remains in get_ipython().kernel.comm_manager.comms
. This leads to multiple comms accumulating after repeated executions, even after clearing the cell output.
Reproduce
- execute in cell
import ipywidgets as widgets
from IPython.display import display
slider = widgets.IntSlider()
display(slider)
- execute in second cell
get_ipython().kernel.comm_manager.comms
-
observe 3 comms present
-
rexecute cell 1
-
observe in cell 2 that 6 comms are present

Expected behavior
Old comms should be closed when the cell output is cleared or replaced, so only one comm remains per widget.
Context
- ipywidgets version 8.1.7
- Operating System and version: macos 15.5
- Browser and version: chrome 138.0.7204.169
Metadata
Metadata
Assignees
Labels
No labels