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
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!
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 https://github.com/jupyter/jupyter_client/blob/8ca76ea1e67c9732a67cab812f8129b68671b9cd/tests/signalkernel.py#L50-L55 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!