Skip to content
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

Add explanation and minor improvement to #581 #586

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion conda_lock/invoke_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def _invoke_conda(
encoding="utf-8",
) as p:
stdout = []
# Using a thread so that both stdout and stderr can be consumed concurrently.
# This avoids a potential deadlock when the child conda process is trying to
# write to stderr (blocked, because the I/O is line-buffered) and conda-lock
# is still trying to read from stdout.
stdout_thread = None
if p.stdout:

def read_stdout() -> None:
Expand All @@ -131,7 +136,7 @@ def read_stdout() -> None:
for line in p.stderr:
stderr.append(line)
logging.error(line.rstrip())
if p.stdout:
if stdout_thread:
stdout_thread.join()

if check_call and p.returncode != 0:
Expand Down
Loading