INNER CODE UNIT · Python

_drain_stdout_worker

MakazhanAlpamys/Soup · src/soup_cli/ui/app.py:246

def _drain_stdout_worker(proc: subprocess.Popen, log_buffer: TrainLogBuffer) -> None:
    """Continuously read stdout of proc until EOF and write to log_buffer."""
    stdout = getattr(proc, "stdout", None)
    if stdout is None:
        log_buffer.mark_done()
        return

    try:
        while True:
            raw_line = stdout.readline()
            if not raw_line or raw_line == b"":
                break
            if isinstance(raw_line, bytes):
                text = raw_line.decode("utf-8", errors="replace").rstrip("\n\r")
            elif isinstance(raw_line, str):
                text = raw_line.rstrip("\n\r")
            else:
                break

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…