Skip to content

[doc] Clarify that Popen.wait is only a busy-loop in certain cases #94033

Open
@hadrielk

Description

@hadrielk

Documentation

In the docs for Popen.wait(), it states:

Note The function is implemented using a busy loop (non-blocking call and short sleeps). Use the asyncio module for an asynchronous wait: see asyncio.create_subprocess_exec.

This is actually only true in a specific circumstance: when both using Posix/Unix and a timeout is given. If, on the other hand, no timeout is given, then it does not go into a busy-loop but instead blocks on os.waitpid(). And for Windows, it never goes into a busy-loop, as it uses the WaitForSingleObject() windows API.

This note in the docs caused me to refactor my code to use asyncio - only later did I actually check what python did internally and discovered the note was wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions