Skip to content

Add test-manual recipe and graceful kernel shutdown on exit#434

Merged
blink1073 merged 2 commits intoCalysto:mainfrom
blink1073:test-manual
Apr 24, 2026
Merged

Add test-manual recipe and graceful kernel shutdown on exit#434
blink1073 merged 2 commits intoCalysto:mainfrom
blink1073:test-manual

Conversation

@blink1073
Copy link
Copy Markdown
Contributor

@blink1073 blink1073 commented Apr 24, 2026

References

Description

Two related improvements for interactive use of MetaKernel Python:

  1. Graceful shutdown on quit() / exit(): do_execute_direct can now raise SystemExit and the base class handles it cleanly — sending an ask_exit payload 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.

  2. just test-manual: A new justfile recipe that installs metakernel_python and launches jupyter console for interactive smoke testing.

Changes

  • metakernel/_metakernel.py: Add _request_shutdown helper (sends ask_exit payload, stops the event loop after 0.5 s). Catch SystemExit from do_execute_direct at both call sites in do_execute and call _request_shutdown.
  • justfile: Add test-manual recipe.
  • pyproject.toml: Add jupyter-console to the dev dependency group.
  • poetry.lock: Updated.

Backwards-incompatible changes

None

Testing

  • just test tests/test_metakernel.py and just test metakernel_python/test_metakernel_python.py — all tests pass
  • just typing — no issues
  • just pre-commit — all hooks pass
  • Manual: just test-manual → type quit() → console exits cleanly, no warning

AI usage

  • Some or all of the content of this PR was generated by AI.
  • The human author has carefully reviewed this PR and run this code.
  • AI tools and models used: Claude Sonnet 4.6 (Claude Code)

@blink1073 blink1073 changed the title Add test-manual justfile recipe and jupyter-console dev dependency Add test-manual recipe and graceful kernel shutdown on exit Apr 24, 2026
@blink1073 blink1073 force-pushed the test-manual branch 3 times, most recently from c57ceea to 64534a8 Compare April 24, 2026 19:30
- 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.
@blink1073 blink1073 enabled auto-merge (squash) April 24, 2026 20:49
@blink1073 blink1073 disabled auto-merge April 24, 2026 20:50
@blink1073 blink1073 merged commit 8563faa into Calysto:main Apr 24, 2026
21 checks passed
@blink1073 blink1073 deleted the test-manual branch April 24, 2026 20:51
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.

1 participant