Skip to content

Commit

Permalink
Break out of timeout, and clarify limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Jan 17, 2024
1 parent c4c437d commit 24086a1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2174,12 +2174,16 @@ Supports a larger number of handles than WaitForMultipleObjects
Note that the handles may be waited on other threads, which could cause
issues for objects like mutexes that become associated with the thread
that was waiting for them.
that was waiting for them. Objects may also be left signalled, even if
the wait fails.
It is generally recommended to use WaitForMultipleObjects whenever
possible, and only switch to BatchedWaitForMultipleObjects for scenarios
where you control all the handles involved, such as your own thread pool
or files.
It is recommended to use WaitForMultipleObjects whenever possible, and
only switch to BatchedWaitForMultipleObjects for scenarios where you
control all the handles involved, such as your own thread pool or
files, and all wait objects are left unmodified by a wait (for example,
manual reset events, threads, and files/pipes).
Overlapped handles returned from this module use manual reset events.
[clinic start generated code]*/

static PyObject *
Expand Down Expand Up @@ -2281,6 +2285,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
long long time_to_deadline = deadline - GetTickCount64();
if (time_to_deadline <= 0) {
err = WAIT_TIMEOUT;
break;
} else if (time_to_deadline < UINT_MAX) {
timeout = (DWORD)time_to_deadline;
}
Expand Down

0 comments on commit 24086a1

Please sign in to comment.