-
Notifications
You must be signed in to change notification settings - Fork 11
fix(run) Fix live / streaming / flushing of output #493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Live updates were broken, e.g. flushing of output during `git clone`
Reviewer's GuideThis PR restores live output streaming by switching subprocess pipes to bytes mode, decoding output with a new utility to preserve carriage returns, and refactoring how stderr and stdout are read and decoded. Class diagram for ProgressCallbackProtocol and process function changesclassDiagram
class ProgressCallbackProtocol {
+__call__(output: str, timestamp: datetime.datetime) -> None
}
class process {
+console_to_str(s: bytes) -> str
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #493 +/- ##
==========================================
- Coverage 54.09% 54.05% -0.04%
==========================================
Files 40 40
Lines 3627 3637 +10
Branches 793 794 +1
==========================================
+ Hits 1962 1966 +4
- Misses 1314 1319 +5
- Partials 351 352 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tony - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/libvcs/_internal/run.py:25` </location>
<code_context>
logger = logging.getLogger(__name__)
+console_encoding = sys.stdout.encoding
+
+
</code_context>
<issue_to_address>
sys.stdout.encoding may be None in some environments.
If console_encoding is None, provide a fallback like 'utf-8' to avoid potential TypeError when decoding.
</issue_to_address>
### Comment 2
<location> `src/libvcs/_internal/run.py:228` </location>
<code_context>
if callback and callable(callback) and proc.stderr is not None:
- line = str(proc.stderr.read(128))
+ line = console_to_str(proc.stderr.read(128))
if line:
callback(output=line, timestamp=datetime.datetime.now())
</code_context>
<issue_to_address>
Reading fixed-size chunks may split multibyte characters.
This approach can cause decode errors or corrupted output. Buffer the data and decode only complete lines, or use an incremental decoder to handle multibyte characters correctly.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Follow up to #485.
Live updates were broken, e.g. flushing of output during
git clone
Summary by Sourcery
Fix live streaming and flushing of subprocess output in
run.py
by switching to byte-mode I/O, preserving carriage returns for progress updates, and decoding output via a console-encoding fallback.Bug Fixes:
console_to_str
helper that tries the console’s encoding and falls back to UTF-8Enhancements:
console_to_str