mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-21302: time.sleep() uses waitable timer on Windows (GH-28483)
On Windows, time.sleep() now uses a waitable timer which has a resolution of 100 ns (10^-7 sec). Previously, it had a solution of 1 ms (10^-3 sec). * On Windows, time.sleep() now calls PyErr_CheckSignals() before resetting the SIGINT event. * Add _PyTime_As100Nanoseconds() function. * Complete and update time.sleep() documentation. Co-authored-by: Livius <egyszeregy@freemail.hu>
This commit is contained in:
parent
8620be99da
commit
58f8adfda3
6 changed files with 161 additions and 56 deletions
|
@ -33,6 +33,7 @@
|
|||
/* Conversion from nanoseconds */
|
||||
#define NS_TO_MS (1000 * 1000)
|
||||
#define NS_TO_US (1000)
|
||||
#define NS_TO_100NS (100)
|
||||
|
||||
|
||||
static void
|
||||
|
@ -568,6 +569,16 @@ _PyTime_AsNanoseconds(_PyTime_t t)
|
|||
}
|
||||
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
_PyTime_t
|
||||
_PyTime_As100Nanoseconds(_PyTime_t t, _PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
return pytime_divide(ns, NS_TO_100NS, round);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTime_AsMicroseconds(_PyTime_t t, _PyTime_round_t round)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue