@@ -413,7 +413,7 @@ static PyTypeObject StructTimeType;
413
413
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x00000002
414
414
#endif
415
415
416
- static DWORD timer_flags = CREATE_WAITABLE_TIMER_HIGH_RESOLUTION ;
416
+ static DWORD timer_flags = 0x00000003 ;
417
417
#endif
418
418
419
419
static PyObject *
@@ -2025,13 +2025,19 @@ time_exec(PyObject *module)
2025
2025
#endif
2026
2026
2027
2027
#if defined(MS_WINDOWS )
2028
- HANDLE timer = CreateWaitableTimerExW (NULL , NULL , timer_flags , TIMER_ALL_ACCESS );
2029
- if (timer == NULL ) {
2030
- // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is not supported.
2031
- timer_flags = 0 ;
2032
- }
2033
- else {
2034
- CloseHandle (timer );
2028
+ if (timer_flags == 0x00000003 ) {
2029
+ DWORD test_flags = CREATE_WAITABLE_TIMER_HIGH_RESOLUTION ;
2030
+ HANDLE timer = CreateWaitableTimerExW (NULL , NULL , test_flags ,
2031
+ TIMER_ALL_ACCESS );
2032
+ if (timer == NULL ) {
2033
+ // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is not supported.
2034
+ timer_flags = 0 ;
2035
+ }
2036
+ else {
2037
+ // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is supported.
2038
+ timer_flags = CREATE_WAITABLE_TIMER_HIGH_RESOLUTION ;
2039
+ CloseHandle (timer );
2040
+ }
2035
2041
}
2036
2042
#endif
2037
2043
@@ -2168,7 +2174,8 @@ pysleep(_PyTime_t timeout)
2168
2174
// SetWaitableTimer(): a negative due time indicates relative time
2169
2175
relative_timeout .QuadPart = - timeout_100ns ;
2170
2176
2171
- HANDLE timer = CreateWaitableTimerExW (NULL , NULL , timer_flags , TIMER_ALL_ACCESS );
2177
+ HANDLE timer = CreateWaitableTimerExW (NULL , NULL , timer_flags ,
2178
+ TIMER_ALL_ACCESS );
2172
2179
if (timer == NULL ) {
2173
2180
PyErr_SetFromWindowsErr (0 );
2174
2181
return -1 ;
0 commit comments