Skip to content

asyncio subprocess stdout occasionally lost (3.11.0 → 3.11.1 regression) #100133

@AMDmi3

Description

@AMDmi3

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_exec started failing in different places in weird ways. It turned out that with some probability asyncio.subprocess.Process.communicate() would now return an empty stdout. Here's a repro:

import asyncio async def main(): attempt = 1 while True: proc = await asyncio.create_subprocess_exec('/bin/echo', 'test', stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) stdout, stderr = await proc.communicate() text = stdout.decode('utf-8').strip() if text != 'test': raise RuntimeError(f'FAIL on attempt {attempt}: output="{text}"') attempt += 1 asyncio.run(main()) 

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:

RuntimeError: FAIL on attempt 3823: output="" 

Your environment

  • CPython versions tested on: 3.11.1
  • Operating system and architecture: FreeBSD 13.1 amd64

Linked PRs

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixestopic-asynciotype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions