Eryk Sun <eryk...@gmail.com> added the comment:

See the related discussion in bpo-41299. The system interrupt period can be 
lowered to 1 ms with timeBeginPeriod() -- or lower with undocumented 
NtSetTimerResolution(). This affects the resolution of dispatcher waits such as 
Sleep() and WaitForSingleObject(), as well as the resolution of 
Query[Unbiased]InterruptTime(). But apparently GetTickCount[64]() has a fixed 
update frequency of 64 ticks/second (15.625 ms period), regardless of the 
system interrupt period. The combination of WaitForSingleObject() with 
GetTickCount64() has marginally better resolution and consistent performance if 
the system interrupt period is lowered to 1 ms.

If a wait needs to be resumable in order to handle SIGINT, and it should 
perform consistently with other waits, then there are two choices. One option 
is to base the timeout on Query[Unbiased]InterruptTime(), for which the 
resolution depends on the system interrupt period. Conversely, if we want all 
waits to perform consistently and independent of the system interrupt period, 
then they should all depend on GetTickCount64(). This could be implemented in 
one place, such as Modules/signalmodule.c, with the addition of _Py_Sleep(), 
Py_WaitForSingleObject(), and _Py_WaitForMultipleObjects(). On the main thread, 
these wait functions would include the SIGINT event and resume the wait if the 
SIGINT handler doesn't raise an exception.

----------
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34535>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to