We need to be able to deliver signals to the current process, both for testing, and to handle an obscure race condition in open_signal_receiver. On POSIX we just use os.kill, but on Windows we use the C raise function (since the kill syscall doesn't exist, and os.kill wrapper does something very different). We get access to it via cffi, loading the api-ms-win-crt-runtime-l1-1-0.dll.
But, it turns out that this is not always the correct DLL to use. In particular, if the Python interpreter is built against the debug version of the CRT, you have to use ucrtbased.dll instead.
Fortunately, this does not affect many people, because people rarely use debug interpreters. But, as far as I know there is no way to figure out which DLL is correct, so right now Trio just can't support debug interpreters on Windows :-(.
Relevant discussion:
Possible solutions:
- Figure out a way to autodetect which CRT the interpreter is using?
- As suggested in bpo-35568, get the stdlib to add a wrapper for
raise so that we don't have to go grovelling around in DLLs by hand?
We need to be able to deliver signals to the current process, both for testing, and to handle an obscure race condition in
open_signal_receiver. On POSIX we just useos.kill, but on Windows we use the Craisefunction (since thekillsyscall doesn't exist, andos.killwrapper does something very different). We get access to it via cffi, loading theapi-ms-win-crt-runtime-l1-1-0.dll.But, it turns out that this is not always the correct DLL to use. In particular, if the Python interpreter is built against the debug version of the CRT, you have to use
ucrtbased.dllinstead.Fortunately, this does not affect many people, because people rarely use debug interpreters. But, as far as I know there is no way to figure out which DLL is correct, so right now Trio just can't support debug interpreters on Windows :-(.
Relevant discussion:
Possible solutions:
raiseso that we don't have to go grovelling around in DLLs by hand?