This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients belopolsky, eryksun, lunixbochs2, p-ganssle, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2021-06-14.21:10:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623705046.84.0.833583863444.issue44328@roundup.psfhosted.org>
In-reply-to
Content
>> Try changing EnterNonRecursiveMutex() to break out of the loop in 
>> this case
>
> This does work, but unfortunately a little too well - in a single 
> test I saw several instances where that approach returned 
> _earlier_ than the timeout.

It's documented that a timeout between N and N+1 ticks can be satisfied anywhere in that range. In practice I see a wider range. In the kernel, variations in wait time could depend on when the due time is calculated in the interrupt cycle, when the next interrupt occurs and the interrupt time is updated, and when the thread is dispatched. A benefit of using a high-resolution external deadline is that waiting will never return early, but it may return later than it otherwise would, e.g. if re-waiting for a remaining 1 ms actually takes 20 ms.

There are many unrelated WaitForSingleObject and WaitForMultipleObjects in the interpreter, extension modules, and code that uses _winapi.WaitForSingleObject and _winapi.WaitForMultipleObjects. For example, time.sleep() allows WAIT_TIMEOUT to override the deadline. I suggest measuring the performance-counter interval for time.sleep(0.001) on both the main thread (Sleep based) and a new thread (WaitForSingleObjectEx based).
History
Date User Action Args
2021-06-14 21:10:46eryksunsetrecipients: + eryksun, paul.moore, belopolsky, vstinner, tim.golden, zach.ware, steve.dower, p-ganssle, lunixbochs2
2021-06-14 21:10:46eryksunsetmessageid: <1623705046.84.0.833583863444.issue44328@roundup.psfhosted.org>
2021-06-14 21:10:46eryksunlinkissue44328 messages
2021-06-14 21:10:46eryksuncreate