You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asyncio: replace _compute_returncode() with os.waitstatus_to_exitcode() #84544
I added os.waitstatus_to_exitcode() in bpo-40094. I propose to replace _compute_returncode() with os.waitstatus_to_exitcode() in Lib/asyncio/unix_events.py to simplify the code *and* to raise an exception if asyncio gets an unexpected wait status from os.waitpid().
There is a comment which suggest to detect when asyncio gets an unexpected status, see the last comment of:
def_compute_returncode(status):
ifos.WIFSIGNALED(status):
# The child process died because of a signal.return-os.WTERMSIG(status)
elifos.WIFEXITED(status):
# The child process exited (e.g sys.exit()).returnos.WEXITSTATUS(status)
else:
# The child exited, but we don't understand its status.# This shouldn't happen, but if it does, let's just# return that status; perhaps that helps debug it.returnstatus
Is there someone interested to propose a PR for that?
I would be interested in looking into this, although I'm not entirely certain either as to how it should be tested at the moment. I'll have to look further into the existing ones.
Activity
vstinner commentedon Apr 22, 2020
I added os.waitstatus_to_exitcode() in bpo-40094. I propose to replace _compute_returncode() with os.waitstatus_to_exitcode() in Lib/asyncio/unix_events.py to simplify the code *and* to raise an exception if asyncio gets an unexpected wait status from os.waitpid().
There is a comment which suggest to detect when asyncio gets an unexpected status, see the last comment of:
Replacing _compute_returncode() with os.waitstatus_to_exitcode() in Lib/asyncio/unix_events.py is trivial. The problem is to update Lib/test/test_asyncio/test_unix_events.py which uses tons of mocks on os.W*() functions (ex: os.WIFEXITED()).
I'm not sure how tests should be updated.
Is there someone interested to propose a PR for that?
aeros commentedon Apr 22, 2020
Victor Stinner wrote:
I would be interested in looking into this, although I'm not entirely certain either as to how it should be tested at the moment. I'll have to look further into the existing ones.
vstinner commentedon Dec 16, 2020
New changeset 99d28c5 by Victor Stinner in branch 'master':
bpo-40364: asyncio uses os.waitstatus_to_exitcode() (GH-23798)
99d28c5