GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — asyncio subprocess stdout occasionally lost (3.11.0 → 3.11.1 regression) · Issue #100133 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
#100154
Closed
asyncio subprocess stdout occasionally lost (3.11.0 → 3.11.1 regression)#100133
#100154
Copy link
Assignees
kumaraditya303
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

@AMDmi3
AMDmi3
opened on Dec 9, 2022
Issue body actions

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

  • GH-100133: fix asyncio subprocess losing stderr and stdout output #100154
  • [3.11] GH-100133: fix asyncio subprocess losing stderr and stdout output (GH-100154) #100398
Reacted by Michal Porteš, asavah and Scott K Logan

Activity

  1. AMDmi3
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 9, 2022
  2. AMDmi3
    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
  3. AMDmi3 commented on Dec 9, 2022

    @AMDmi3
    AMDmi3
    on Dec 9, 2022
    ContributorAuthor
    More actions

    @kumaraditya303 FYI, there were some commits to asyncio subprocess from you recently.

  4. mportesdev commented on Dec 9, 2022

    @mportesdev
    mportesdev
    on Dec 9, 2022
    More actions

    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/21788

  5. mportesdev commented on Dec 9, 2022

    @mportesdev
    mportesdev
    on Dec 9, 2022
    More actions

    For 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()))
  6. AlexWaygood
    added
    topic-asyncio
    on Dec 9, 2022
  7. ezio-melotti
    added this to asyncioon Dec 9, 2022
  8. ezio-melotti
    moved this to Todo in asyncioon Dec 9, 2022
  9. AlexWaygood
    added
    3.11only security fixesonly security fixes
    on Dec 9, 2022
  10. gvanrossum commented on Dec 9, 2022

    @gvanrossum
    gvanrossum
    on Dec 9, 2022
    Member
    More actions

    Let’s bisect that repro to a specific commit.

  11. kumaraditya303
    added
    3.12only security fixesonly security fixes
    on Dec 10, 2022
  12. kumaraditya303
    self-assigned this
    on Dec 10, 2022
  13. kumaraditya303
    linked a pull request that will close this issueGH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` output #100154on Dec 10, 2022
  14. gvanrossum commented on Dec 12, 2022

    @gvanrossum
    gvanrossum
    on Dec 12, 2022
    Member
    More actions

    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.

  15. kumaraditya303 commented on Dec 12, 2022

    @kumaraditya303
    kumaraditya303
    on Dec 12, 2022
    Contributor
    More actions

    Thanks for the bug report, I have a fix for this #100154, can you verify it that it works as you expect? Thanks @AMDmi3

  16. AMDmi3 commented on Dec 12, 2022

    @AMDmi3
    AMDmi3
    on Dec 12, 2022
    ContributorAuthor
    More actions

    The fix works for me, thank you!

  17. kumaraditya303
    closed this as completedin #100154on Dec 21, 2022
  18. Repository owner moved this from Todo to Done in asyncioon Dec 21, 2022
  19. kumaraditya303
    added a commit that references this issue on Dec 21, 2022

    GH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` outp…

    a7715cc
  20. miss-islington
    added 2 commits that reference this issue on Dec 21, 2022

    pythonGH-100133: fix `asyncio` subprocess losing `stderr` and `stdout…

    cc25cd1

    GH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` outp…

    ae8520c
  21. freebsd-git
    added a commit that references this issue on Dec 23, 2022

    lang/python311: fix asyncio.subprocess regression

    41dbb76
  22. iritkatriel
    added a commit that references this issue on Dec 28, 2022

    Merged main into regmachine branch (#50)

    fdc73cb
  23. hroncok
    added a commit that references this issue on Jan 12, 2023

    00395: pythonGH-100133: fix `asyncio` subprocess losing `stderr` and …

    da08f25
  24. jeffsf
    added a commit that references this issue on Jan 23, 2023

    Add tests for tracing down the issue with bluetoothctl version

    aa1a558
  25. camachat
    added a commit that references this issue on Jul 22, 2026

    lang/python311: fix asyncio.subprocess regression

    547505e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kumaraditya303
    kumaraditya303

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

  • asyncio
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.