Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4bac435

Browse files
authoredFeb 11, 2024
Merge pull request #586 from tadeu/deadlock-followup
Add explanation and minor improvement to #581
2 parents f592f2d + 3a9f3c3 commit 4bac435

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎conda_lock/invoke_conda.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def _invoke_conda(
116116
encoding="utf-8",
117117
) as p:
118118
stdout = []
119+
# Using a thread so that both stdout and stderr can be consumed concurrently.
120+
# This avoids a potential deadlock when the child conda process is trying to
121+
# write to stderr (blocked, because the I/O is line-buffered) and conda-lock
122+
# is still trying to read from stdout.
123+
stdout_thread = None
119124
if p.stdout:
120125

121126
def read_stdout() -> None:
@@ -131,7 +136,7 @@ def read_stdout() -> None:
131136
for line in p.stderr:
132137
stderr.append(line)
133138
logging.error(line.rstrip())
134-
if p.stdout:
139+
if stdout_thread:
135140
stdout_thread.join()
136141

137142
if check_call and p.returncode != 0:

0 commit comments

Comments
 (0)
Please sign in to comment.