homepage

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 William.Schwartz
Recipients William.Schwartz, eryksun, ncoghlan, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2021年01月19日.21:10:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611090622.13.0.00610089898522.issue42962@roundup.psfhosted.org>
In-reply-to
Content
>For a new process group, the cancel event is initially ignored, but the break event is always handled. To enable the cancel event, the process must call SetConsoleCtrlHandler(NULL, FALSE), such as via ctypes with kernel32.SetConsoleCtrlHandler(None, False). I think the signal module should provide a function to enable/disable Ctrl+C handling without ctypes, and implicitly enable it when setting a new SIGINT handler.
That's what Lib/test/win_console_handler.py:39 does. What I don't understand is why that's necessary. Isn't that what PyConfig.install_signal_handlers is supposed to do?
Which brings me to how I ended up here in the first place: I wanted to write a test that PyConfig.install_signal_handlers is set in an embedded instance of Python I'm working with. In outline, the following test works on both Windows and macOS *except on Windows running under Tox*.
@unittest.removeHandler
def test_signal_handlers_installed(self):
 SIG = signal.SIGINT
 if sys.platform == 'win32':
 SIG = signal.CTRL_C_EVENT
 with self.assertRaises(KeyboardInterrupt):
 os.kill(os.getpid(), SIG)
 if sys.platform == 'win32':
 time.sleep(.1) # Give handler's thread time to join
Using SetConsoleCtrlHandler if I detect that I'm running on Windows under Tox would, if I understand correctly, hide whether PyConfig.install_signal_handlers was set before the Python I'm running in started, right? (I know this isn't the right venue for discussing my embedding/testing problem. But maybe the use case informs the pending discussion of what to do about os.kill's semantics.)
History
Date User Action Args
2021年01月19日 21:10:22William.Schwartzsetrecipients: + William.Schwartz, paul.moore, ncoghlan, vstinner, tim.golden, zach.ware, eryksun, steve.dower
2021年01月19日 21:10:22William.Schwartzsetmessageid: <1611090622.13.0.00610089898522.issue42962@roundup.psfhosted.org>
2021年01月19日 21:10:22William.Schwartzlinkissue42962 messages
2021年01月19日 21:10:22William.Schwartzcreate

AltStyle によって変換されたページ (->オリジナル) /