Eryk Sun <eryk...@gmail.com> added the comment:
If WaitForSingleObjectEx fails, do you think the system error code should be raised as an OSError? Probably an invalid-handle or access-denied error is too cryptic here. It may be better to raise something like RuntimeError('time.sleep(): invalid SIGINT event handle'). > You could test this by getting the event and CloseHandle-ing it. Yes, that's a simpler approach. It should work in a child process that's well controlled. I was thinking of a less controlled environment, in which there's a chance that another waitable object will reuse the handle, such as a file object. The test would be reliable regardless of process context (but only in the main thread, of course) if there were a _PyOS_SetSigintEvent function -- or if sigint_event were directly accessible in _testcapimodule. It could just temporarily set a duplicate handle with no access. For example: >>> h1 = CreateEvent(None, True, True, None) >>> WaitForSingleObject(h1, 0) 0 >>> hp = GetCurrentProcess() >>> h2 = DuplicateHandle(hp, h1, hp, 0, False, 0) >>> WaitForSingleObject(h2, 0) Traceback (most recent call last): File "<stdin>", line 1, in <module> pywintypes.error: (5, 'WaitForSingleObject', 'Access is denied.') ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40913> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com