Add test-manual recipe and graceful kernel shutdown on exit#434
Merged
blink1073 merged 2 commits intoCalysto:mainfrom Apr 24, 2026
Merged
Add test-manual recipe and graceful kernel shutdown on exit#434blink1073 merged 2 commits intoCalysto:mainfrom
blink1073 merged 2 commits intoCalysto:mainfrom
Conversation
c57ceea to
64534a8
Compare
- Add _request_shutdown to the MetaKernel base class: catches SystemExit from do_execute_direct, sends an ask_exit payload to the client, adds a log filter to suppress the parent-poller warning (since shutdown is intentional), then calls os._exit(0) after 0.1s. - Add just test-manual recipe that installs metakernel_python and launches jupyter console for interactive smoke testing. - Add jupyter-console to the dev dependency group.
…ent-exit warning Python logging filters on a Logger only apply to records logged directly to it, not to records propagated *through* it. The parent poller logs via traitlets.log.get_logger(), which returns the app's logger (self.log). Adding the filter only to logging.root had no effect. Add it to self.log as well to reliably suppress the spurious warning during intentional shutdown.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References
Description
Two related improvements for interactive use of MetaKernel Python:
Graceful shutdown on
quit()/exit():do_execute_directcan now raiseSystemExitand the base class handles it cleanly — sending anask_exitpayload to the client and stopping the event loop — instead of leaving the kernel alive until the parent-process monitor fires the "Parent appears to have exited" warning.just test-manual: A new justfile recipe that installsmetakernel_pythonand launchesjupyter consolefor interactive smoke testing.Changes
metakernel/_metakernel.py: Add_request_shutdownhelper (sendsask_exitpayload, stops the event loop after 0.5 s). CatchSystemExitfromdo_execute_directat both call sites indo_executeand call_request_shutdown.justfile: Addtest-manualrecipe.pyproject.toml: Addjupyter-consoleto thedevdependency group.poetry.lock: Updated.Backwards-incompatible changes
None
Testing
just test tests/test_metakernel.pyandjust test metakernel_python/test_metakernel_python.py— all tests passjust typing— no issuesjust pre-commit— all hooks passjust test-manual→ typequit()→ console exits cleanly, no warningAI usage