Skip to content

fix(run_cmd): read subprocess stdout in chunks instead of single characters - #5625

Open
lx3133584 wants to merge 1 commit into
Aider-AI:mainfrom
lx3133584:fix/run-cmd-chunk-read
Open

fix(run_cmd): read subprocess stdout in chunks instead of single characters#5625
lx3133584 wants to merge 1 commit into
Aider-AI:mainfrom
lx3133584:fix/run-cmd-chunk-read

Conversation

@lx3133584

Copy link
Copy Markdown

Summary

Fixes #5624.

In run_cmd_subprocess(), stdout was previously read one character at a time (process.stdout.read(1)) with print(chunk, end="", flush=True) in each iteration. For commands producing large output (such as verbose test suites or builds during /run, /test, or --auto-test), this introduced significant Python interpreter and text-decoding overhead.

Changes

  • Update run_cmd_subprocess() to read stdout in 4KB chunks (process.stdout.read(4096)) while preserving real-time output printing and overall stdout capture.
  • Add a unit test verifying run_cmd_subprocess reads stdout in chunks.

Verification

  • Ran pytest tests/basic/test_run_cmd.py to verify RED (failed on single-char read) and GREEN (passed on chunk read) states.

…acters

Fixes Aider-AI#5624

Signed-off-by: Liang Xu <lx3133584@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/run and /test read command output one character at a time (~60x slower than bulk reads)

1 participant