Skip to content

Inconsistent documentation about calling subprocess inside async function in a child thread #108224

@temach

Description

@temach

Documentation

This page states: https://docs.python.org/3/library/asyncio-dev.html#concurrency-and-multithreading

To handle signals and to execute subprocesses, the event loop must be run in the main thread.

For me this means that if I want to use subprocess call my async function must be triggered by loop on the main thread. In other words async functions can not call subprocess when running in child thread.

However this page states: https://docs.python.org/3/library/asyncio-subprocess.html#subprocess-and-threads

Standard asyncio event loop supports running subprocesses from different threads by default.

To me this means that I can spawn a child thread, call async function inside it, and that async function is free to call subprocess without problems.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesdocsDocumentation in the Doc dirtopic-asyncio

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions