Message371413
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.') |
|
Date |
User |
Action |
Args |
2020-06-12 19:50:09 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower |
2020-06-12 19:50:09 | eryksun | set | messageid: <1591991409.33.0.500698214841.issue40913@roundup.psfhosted.org> |
2020-06-12 19:50:09 | eryksun | link | issue40913 messages |
2020-06-12 19:50:08 | eryksun | create | |
|