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 vstinner
Recipients aeros, asvetlov, chris.jerdonek, jstasiak, miss-islington, njs, vstinner, yselivanov
Date 2021-06-04.20:49:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622839760.28.0.197425393431.issue38323@roundup.psfhosted.org>
In-reply-to
Content
When I reproduce test_cancel_make_subprocess_transport_exec() hang, the problem is that the C signal handler is called with SIGCHLD when the child process completes, but the Python signal handler is not called.

Python is "blocked" in a selector (maybe select.select(), it doesn't matter). I guess that the selector is interrupted by a signal (even if asyncio calls signal.setinterrupt(SIGCHLD, False)), but since the signal handler doesn't raise an exception, the syscall is restarted: see the PEP 475.

I understood that the asyncio event loop only gets the opportunity to call the Python signal handler if there is a pending asyncio event (call_soon, call_timer, event on a tracked FD, whatever). If the signal arrives when the event loop is idle, the Python signal handler will never be called since the selector is called with timeout=0 (blocking mode).

MultiLoopChildWatcher must ensures that the event loop is awaken when it receives a signal by using signal.setwakeup(). This is done by _UnixSelectorEventLoop.add_signal_handler(). Maybe MultiLoopChildWatcher could reuse this function, rather than calling directly signal.signal().
History
Date User Action Args
2021-06-04 20:49:20vstinnersetrecipients: + vstinner, njs, asvetlov, chris.jerdonek, yselivanov, jstasiak, miss-islington, aeros
2021-06-04 20:49:20vstinnersetmessageid: <1622839760.28.0.197425393431.issue38323@roundup.psfhosted.org>
2021-06-04 20:49:20vstinnerlinkissue38323 messages
2021-06-04 20:49:20vstinnercreate