Description
As noted in #52, there are some events on Windows that can only be detected by calling one of the WaitFor
family of functions (WaitForSingleObject
, WaitForSingleObjectEx
, WaitForMultipleObjects
, etc. etc.). Some examples include child process exit (required for #4), and detecting console input (required for #174).
To resolve this issue, we should provide a trio.hazmat.WaitForSingleObject
function that takes a HANDLE
, and waits for it, and is cancellable.
The most straightforward way to do this is to allocate a thread to sit in WaitForSingleObjectEx
, which can do an "alertable wait", which means that it's possible to cause the function to wake up early by calling QueueUserAPC
. So we would use QueueUserAPC
from inside our abort callback to implement cancellation. There are some more notes in _io_windows.py
.