Skip to content

Use asyncio.Lock around subshell message handling#1430

Merged
ianthomas23 merged 7 commits intomainfrom
asyncio_lock
Sep 29, 2025
Merged

Use asyncio.Lock around subshell message handling#1430
ianthomas23 merged 7 commits intomainfrom
asyncio_lock

Conversation

@ianthomas23
Copy link
Collaborator

Use asyncio.Lock around subshell message handling.

This decreases the flakiness of some JupyterLab UI tests when run locally.

@ianthomas23
Copy link
Collaborator Author

Rebased on top of #1431.

@ianthomas23 ianthomas23 force-pushed the asyncio_lock branch 2 times, most recently from fd04983 to 880283d Compare September 29, 2025 08:24
@ianthomas23 ianthomas23 merged commit 7b41bc6 into main Sep 29, 2025
74 of 75 checks passed
@ianthomas23 ianthomas23 deleted the asyncio_lock branch September 29, 2025 08:41
@jph00
Copy link

jph00 commented Feb 6, 2026

@ianthomas23 FYI this seems to have caused lockups in nbclassic. See #1471 .

@ianthomas23
Copy link
Collaborator Author

@jph00 It is possible that it is not needed, IDK.

@jph00
Copy link

jph00 commented Feb 6, 2026

@jph00 It is possible that it is not needed, IDK.

Yeah I've been testing without it and it's working great. To get unstuck I've released a version which removes the lock:
https://github.com/AnswerDotAI/ipyk-unlock

@ianthomas23
Copy link
Collaborator Author

Do you mean it is working great just for your particular use case, or have you tried it with other reasonable use cases of ipykernel?

@jph00
Copy link

jph00 commented Feb 6, 2026

Do you mean it is working great just for your particular use case, or have you tried it with other reasonable use cases of ipykernel?

I've tested it with Jupyter Lab, nbclassic, and solveit (our proprietary app), using a number of notebooks which previously ipykernel 7 had struggled with.

@ianthomas23
Copy link
Collaborator Author

Unfortunately it would also need to be tested in JupyterLab CI, i.e. an environment in which tens of messages are sent in quick succession for no sensible reason but that it what it chooses to do.

@jph00
Copy link

jph00 commented Feb 6, 2026

Yeah understood, I'm not suggesting you make changes - it's just FYI.

BTW I also created a test which sends lots of messages across lots of subshells and it fails with both the lock or no lock. I spent a few weeks trying to fix it but it seems very hard indeed to make subshells work reliably. For some reason in solveit and nbclassic they seem to exercise ipykernel in a way that is more susceptible to causing lockups. Anyhoo I'm happy to have something working now and to have a solution for other nbclassic users! :D

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