-
Notifications
You must be signed in to change notification settings - Fork 66
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
_subprocess: Fix pip install
log window not showing
#567
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ def run(args: Sequence[str], *, log_stdout: bool = False, state: AuditState = Au | |
|
||
terminated = False | ||
stdout = b"" | ||
stderr = b"" | ||
|
||
# NOTE: We use `poll()` to control this loop instead of the `read()` call | ||
# to prevent deadlocks. Similarly, `read(size)` will return an empty bytes | ||
|
@@ -54,11 +53,14 @@ def run(args: Sequence[str], *, log_stdout: bool = False, state: AuditState = Au | |
terminated = process.poll() is not None | ||
# NOTE(ww): Buffer size chosen arbitrarily here and below. | ||
stdout += process.stdout.read(4096) # type: ignore | ||
stderr += process.stderr.read(4096) # type: ignore | ||
state.update_state( | ||
f"Running {pretty_args}", stdout.decode(errors="replace") if log_stdout else None | ||
) | ||
|
||
# NOTE(alex): For reasons I'm unsure about, reading the stderr stream in | ||
# real time seems to interfere with stdout and cause us to read nothing. | ||
# Let's wait until the process is terminated before reading stderr. | ||
stderr = process.stderr.read() # type: ignore | ||
Comment on lines
+60
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'm a little worried this might cause deadlocks in some (unlikely) conditions: I can imagine a case where Specifically, that should only happen if |
||
if process.returncode != 0: | ||
raise CalledProcessError( | ||
f"{pretty_args} exited with {process.returncode}", | ||
|
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.
Needs relocating under
[Unreleased]
🙂