Message395119
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(). |
|
Date |
User |
Action |
Args |
2021-06-04 20:49:20 | vstinner | set | recipients:
+ vstinner, njs, asvetlov, chris.jerdonek, yselivanov, jstasiak, miss-islington, aeros |
2021-06-04 20:49:20 | vstinner | set | messageid: <1622839760.28.0.197425393431.issue38323@roundup.psfhosted.org> |
2021-06-04 20:49:20 | vstinner | link | issue38323 messages |
2021-06-04 20:49:20 | vstinner | create | |
|