Repository navigation
asyncio subprocess stdout occasionally lost (3.11.0 → 3.11.1 regression) #100133
Copy link
Copy link
Closed
Closed
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Dec 9, 2022 - changed the title
[-]asyncio subprocess stdout lost (3.11.0 → 3.11.1 regression)[/-][+]asyncio subprocess stdout occasionally lost (3.11.0 → 3.11.1 regression)[/+]on Dec 9, 2022 @kumaraditya303 FYI, there were some commits to asyncio subprocess from you recently.
I experienced this too, reported it here with some additional info:
https://discuss.python.org/t/python-3-11-1-async-subprocess-stdout-lost-when-piped/21788For me, the following script always results with an unexpected
[b'', b'', b'baz\n']both in Python 3.11.1 and 3.12.0a3.import asyncio async def get_command_stdout(cmd, *args): proc = await asyncio.create_subprocess_exec( cmd, *args, stdout=asyncio.subprocess.PIPE, ) stdout, _ = await proc.communicate() return stdout async def main(): return await asyncio.gather( get_command_stdout('echo', 'foo'), get_command_stdout('echo', 'bar'), get_command_stdout('echo', 'baz'), ) if __name__ == '__main__': print(asyncio.run(main()))
Let’s bisect that repro to a specific commit.
- linked a pull request that will close this issueGH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` output #100154
on Dec 10, 2022 The bisection points to
commit 7015e1379791cbf19908cd1a7c668a5d6e7165d5 Date: Wed Oct 5 10:15:31 2022 gh-88050: Fix asyncio subprocess to kill process cleanly when process is blocked (#32073)We will get it fixed in 3.11.2.
The fix works for me, thank you!
- added a commit that references this issue
on Dec 21, 2022 - added a commit that references this issue
on Dec 23, 2022 - added a commit that references this issue
on Dec 28, 2022 - added a commit that references this issue
on Jan 23, 2023 - added a commit that references this issue
on Jul 22, 2026
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Bug report
So, I've updated python from 3.11.0 to 3.11.1 and one of my utilities which runs a lot of external processes with
asyncio.create_subprocess_execstarted failing in different places in weird ways. It turned out that with some probabilityasyncio.subprocess.Process.communicate()would now return an empty stdout. Here's a repro:You may have to wait somewhat for the problem to reproduce, but for me it fails in under 15 seconds more or less reliably. Possible output:
Your environment
Linked PRs
asynciosubprocess losingstderrandstdoutoutput #100154asynciosubprocess losingstderrandstdoutoutput (GH-100154) #100398