Skip to content

Provide an API that does WaitForSingleObject on Windows #233

Closed
@njsmith

Description

@njsmith

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions