Conversation
|
@ptosco thanks, this is awesome to have this potentially fixed after so long! Can you share more about the relationship of the two PRs (i.e. does one need the other, or are they independent, or will things be okay to have one or the other patches in place, just not fully fixed unless you have both)? I mainly want to understand if we need to update any dependencies, or if there are any negative consequences for other implementations that aren't jupyter-client or kernels that aren't ipykernel that won't have these changes. |
for more information, see https://pre-commit.ci
|
@minrk Thanks for your comment; I have addressed your concern, which I also had, by conditionally setting the |
|
Thanks! Sorry, I think I might have given the wrong impression. I don't think we should be checking ipykernel inside the Jupyter-client process. There's every chance ipykernel is not in the same env, or it is and the kernel isn't ipykernel, or it is ipykernel and a different version from what's in the client's env. I only wanted to know: what are the consequences when:
We can decide how to address it with that information, but it is not knowable from within the client process. What I don't know right now is what will actually happen in case 1, so I don't yet know what to suggest we do. If it's not safe, we need to have a plan for discovering this support from the kernelspec, because Python APIs can't work. |
Currently, a long-running C Python module executed on Windows in a Jupyter kernel can only be interrupted by sending twice the "Interrupt kernel" signal.
This happens because the first interrupt signal is intercepted by
ipykernel/parentpoller.pyand as it is set to auto-reset, it will not reach a C Python module listening for the same signal. At the time, theinterrupt_main()call scheduled byipykernel/parentpoller.pywill not be executed as the main Python thread is blocked by the long-running C Python module.Only when the "Interrupt kernel" is issued again the C Python module will be interrupted.
This PR sets the
CreateEventbManualResetBoolean flag totrue, thus requiring the interrupt event to be manually reset by the receiver. This makes it possible for a listening C Python module to be reached by the signal and hence be interrupted, without requiring the interrupt signal to be issued twice.This can be conveniently tested through the attached
waitlooptest Python module, which can be installed on all platforms supported by Jupyter by unzipping waitloop_module.zip and then runningpip install .in thewaitloop_moduledirectory:Python interpreter - all platforms
Jupyter notebook - Windows platform
Jupyter notebook - non-Windows platforms
WIth the current Jupyter version, on Windows it is necessary to issue "Interrupt kernel" twice to interrupt
waitloop, whereas on non-Windows platforms it is sufficient to issue the command once,After merging this PR and the sister PR #1434 in the
ipykernelrepo, a single "Interrupt kernel" will stopwaitloopalso on Windows, as expected.