Skip to content

Commit

Permalink
Add comment and minor improvement to #581
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeu committed Jan 18, 2024
1 parent 068bd19 commit 3a9f3c3
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 3a9f3c3

Please sign in to comment.