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 chris.jerdonek
Recipients aeros, asvetlov, chris.jerdonek, vstinner, yselivanov
Date 2020-05-09.04:44:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588999483.35.0.238102838658.issue38323@roundup.psfhosted.org>
In-reply-to
Content
I looked into this a little after reproducing it locally.

What I found is that MultiLoopChildWatcher._sig_chld() *is* called. It's just that it's only called immediately after timeout=5 has elapsed. (The timeout=5 was added by Andrew here: https://github.com/python/cpython/blob/7f7e706d78ab968a1221c6179dfdba714860bd12/Lib/test/test_asyncio/test_subprocess.py#L480 )

Consider this line in asyncio.tasks.wait_for(), which is to trigger the timeout:
https://github.com/python/cpython/blob/7f7e706d78ab968a1221c6179dfdba714860bd12/Lib/asyncio/tasks.py#L476

  timeout_handle = loop.call_later(timeout, _release_waiter, waiter)

I put some debug statements inside _release_waiter, and I found that _sig_chld() is called after the timeout has elapsed and before _release_waiter starts. So basically, it looks like CPython is holding onto the signal, and waiting for the loop to do something more before running the handler and calling the _sig_chld().

The code base already has logic to skip running signal handlers in various cases, but I don't know whether it relates to this issue:
https://github.com/python/cpython/blob/7f7e706d78ab968a1221c6179dfdba714860bd12/Python/ceval.c#L1410-L1425

It seems like there are a number of issues on the tracker related to signals (some solved and others not, e.g. https://bugs.python.org/issue21895 ). So it looks to me like this could point to a deeper issue between asyncio and CPython's signal handling.
History
Date User Action Args
2020-05-09 04:44:43chris.jerdoneksetrecipients: + chris.jerdonek, vstinner, asvetlov, yselivanov, aeros
2020-05-09 04:44:43chris.jerdoneksetmessageid: <1588999483.35.0.238102838658.issue38323@roundup.psfhosted.org>
2020-05-09 04:44:43chris.jerdoneklinkissue38323 messages
2020-05-09 04:44:43chris.jerdonekcreate