collect_process()

Drain a subprocess’s stdout and stderr concurrently and wait for it to exit.

Usage

Source

collect_process(
    proc,
    *,
    stderr_tee=None,
)

Parameters

proc: asyncio.subprocess.Process

A process created with both stdout and stderr piped.

stderr_tee: Callable[[bytes], None] | None = None
Callback invoked with each stderr line as it arrives.

Returns

tuple[bytes, bytes, int]
A (stdout, stderr, returncode) tuple.