Skip to content

asyncio.subprocess blocked event loop unexpectedly on MacOS #158287

Description

@starstreammm

Bug report

Bug description:

After upgrading to 3.14.7 & macOS 27, this bug has happened.

When pausing the subprocess created by asyncio.create_subprocess_exec, it will blocked the whole event loop on MacOS.

Here is a minimal test code:

import asyncio
import psutil

async def main():
    proc = await asyncio.create_subprocess_exec(
        "sleep",
        "1000",
    )
    psutil.Process(proc.pid).suspend()

    print("child pid:", proc.pid, flush=True)

    count = 0
    while True:
        await asyncio.sleep(1)
        print(f"alive {count}", flush=True)
        count += 1

asyncio.run(main())

Expectly, it should print:

child pid: xxxxx
alive 0
alive 1
...

However, it just prints child pid: xxxxx, without any alive.

This issue isn't caused by psutil because the same result was got with kill -STOP xxxxx.

This runs well on Windows, but not on MacOS. This didn't happen on the previous version of 3.14.

CPython versions tested on:

3.14

Operating systems tested on:

macOS, Windows

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions