FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use thread lock to support comms via subshells by ianthomas23 · Pull Request #603 · matplotlib/ipympl · GitHub

Use thread lock to support comms via subshells - #603

Merged
martinRenou merged 1 commit into
matplotlib:mainfrom
ianthomas23:lock-for-subshells-2
Aug 25, 2025
Merged

Use thread lock to support comms via subshells#603
martinRenou merged 1 commit into
matplotlib:mainfrom
ianthomas23:lock-for-subshells-2

Conversation

Copy link
Copy Markdown
Member

The upcoming ipykernel 7.0.0 release will support subshells which are separate threads of execution within a kernel process. JupyterLab has already been updated to deal with subshells on kernels that support them and this includes options for running comms over subshells (jupyterlab/jupyterlab#17363). This PR contains changes that are needed in ipympl to support subshells, specifically use of a threading.Lock in the python code that accesses global state such at Matplotlib's Gcf and ipython.display. Without this we see problems such as plots not being displayed as one thread can be, for example, modifying a collection in Gcf whilst another is reading it. Strictly speaking we only need to lock when one thread is writing to a global as we can tolerate multiple non-modifying reads at the same time, but I have preferred to keep the changes as simple and understandable as possible but putting the locks at a high level in each of the functions that needs it.

Above is a screenshot reproducing the problem using latest commit 5e068ed, showing that the third plot is not displayed. To reproduce this use the latest jupyterlab and precisely ipykernel==7.0.0a2, and in Lab's Settings Editor select "Kernel comms over subshells" to be "One subshell per comm-target". It does not occur every time, but this is the setting that I have found most likely to produce the problem. After this PR, all plots display correctly.

Copy link
Copy Markdown
Contributor

👈 Launch a binder notebook on branch ianthomas23/ipympl/lock-for-subshells-2

martinRenou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

martinRenou merged commit 1ef9f67 into matplotlib:main Aug 25, 2025
8 of 9 checks passed
ianthomas23 deleted the lock-for-subshells-2 branch September 2, 2025 08:47

Copy link
Copy Markdown
Member Author

We will need a new release of ipympl with this before ipykernel 7.0.0 is released. I think it could be 0.9.8 as this isn't really new functionality, or 0.10.0 is that is preferred.

Copy link
Copy Markdown
Member

Sounds good! We can make it 0.9.8

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL