Support ipykernel's use of anyio in test_signal_kernel_subprocesses #1034
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.
Following the switch in ipykernel to use anyio (ipython/ipykernel#1079 and subsequent PRs) its downstream testing against jupyter_client fails with a timeout in the test
A recent example CI run is https://github.com/ipython/ipykernel/actions/runs/10416809602/job/28849785992.
The failure occurs in
jupyter_client/tests/signalkernel.py
Lines 50 to 55 in 8ca76ea
because we can no longer catch a
KeyboardInterrupt
interrupt in this way as anyio's support for this requires it to be implemented in a specific way as documented at https://anyio.readthedocs.io/en/stable/signals.html#handling-keyboardinterrupt-and-systemexit to support all the various async backends.The problem occurs in test code only, so this PR changes that test code so for ipykernel >= 7 it uses the recommended anyio solution and otherwise falls back to the current implementation. This passes locally for me on both Linux and macOS. There is no explicit testing of jupyter_client CI against ipykernel main branch, so to test this we either just merge it and rerun ipykernel's downstream tests, or we have to add an extra temporary CI to use ipykernel main branch.
There may well be other failures in CI once this passes as it currently stops on this failure. I see different subsequent failures on Linux and macOS so we will have to see what happens in CI!