This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-06-12.19:50:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591991409.33.0.500698214841.issue40913@roundup.psfhosted.org>
In-reply-to
Content
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.')
History
Date User Action Args
2020-06-12 19:50:09eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2020-06-12 19:50:09eryksunsetmessageid: <1591991409.33.0.500698214841.issue40913@roundup.psfhosted.org>
2020-06-12 19:50:09eryksunlinkissue40913 messages
2020-06-12 19:50:08eryksuncreate