WindowsProcessReader(
self,
process: subprocess.Popen[str],
)| Name | Type |
|---|---|
| process | subprocess.Popen[str] |
Read both captured pipes by polling instead of with reader threads.
subprocess.communicate starts a thread for each pipe on Windows. Those
threads hold the pipe until the write end closes, so a caller cannot close
the pipes to stop waiting for a descendant that inherited them. This reader
polls instead, which leaves the caller free to close the pipes at any time.
The process must be in text mode, because the reader takes the encoding and
error handler from each pipe. Nothing may read the pipes before this reader
is created. Each pipe is decoded incrementally as it is read, so repeated
calls to communicate keep the text already decoded, and an encoded
character split across two reads is held until the rest of it arrives.
The caller owns termination and pipe cleanup if communicate raises.