Skip to content

Conversation

@ianthomas23
Copy link
Contributor

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

tests/test_kernelmanager.py::TestKernelManager::test_signal_kernel_subprocesses

A recent example CI run is https://github.com/ipython/ipykernel/actions/runs/10416809602/job/28849785992.

The failure occurs in

try:
time.sleep(10)
except KeyboardInterrupt:
reply["user_expressions"]["interrupted"] = True
else:
reply["user_expressions"]["interrupted"] = False

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!

@minrk minrk merged commit b5cb375 into jupyter:main Sep 17, 2024
@ianthomas23 ianthomas23 deleted the anyio-test-fix branch September 17, 2024 12:10
@ianthomas23
Copy link
Contributor Author

I have confirmed that the ipykernel downstream tests using jupyter_client 8.6.3 now pass: https://github.com/ipython/ipykernel/actions/runs/10849861591

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