File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 88
99INFINITE = 0xFFFFFFFF
1010WAIT_FAILED = 0xFFFFFFFF
11+ CREATE_WAITABLE_TIMER_MANUAL_RESET = 0x00000001
1112CREATE_WAITABLE_TIMER_HIGH_RESOLUTION = 0x00000002
1213
1314
@@ -22,13 +23,14 @@ def sleep(sleep_for: float) -> None:
2223 handle = kernel32 .CreateWaitableTimerExW (
2324 None ,
2425 None ,
25- CREATE_WAITABLE_TIMER_HIGH_RESOLUTION ,
26+ CREATE_WAITABLE_TIMER_HIGH_RESOLUTION | CREATE_WAITABLE_TIMER_MANUAL_RESET ,
2627 0x1F0003 ,
2728 )
2829 if not handle :
2930 time_sleep (sleep_for )
3031 return
3132
33+ sleep_for -= 1 / 1000
3234 if not kernel32 .SetWaitableTimer (
3335 handle ,
3436 ctypes .byref (LARGE_INTEGER (int (sleep_for * - 10_000_000 ))),
@@ -38,8 +40,10 @@ def sleep(sleep_for: float) -> None:
3840 0 ,
3941 ):
4042 kernel32 .CloseHandle (handle )
43+ print ("error" )
4144 time_sleep (sleep_for )
4245 return
4346
44- kernel32 .WaitForSingleObject (handle , INFINITE )
47+ if kernel32 .WaitForSingleObject (handle , INFINITE ) == WAIT_FAILED :
48+ time_sleep (sleep_for )
4549 kernel32 .CloseHandle (handle )
You can’t perform that action at this time.
0 commit comments