Skip to content

Commit

Permalink
Merge pull request #581 from tadeu/fix-deadlock
Browse files Browse the repository at this point in the history
Avoid I/O deadlock with conda
  • Loading branch information
maresb authored Jan 18, 2024
2 parents aa49149 + 62c44ac commit 555046d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions conda_lock/invoke_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shutil
import subprocess
import tempfile
import threading

from distutils.version import LooseVersion
from typing import IO, Dict, Iterator, List, Optional, Sequence, Union
Expand Down Expand Up @@ -116,14 +117,22 @@ def _invoke_conda(
) as p:
stdout = []
if p.stdout:
for line in _process_stdout(p.stdout):
logging.info(line)
stdout.append(line)

def read_stdout() -> None:
assert p.stdout is not None
for line in _process_stdout(p.stdout):
logging.info(line)
stdout.append(line)

stdout_thread = threading.Thread(target=read_stdout)
stdout_thread.start()
stderr = []
if p.stderr:
for line in p.stderr:
stderr.append(line)
logging.error(line.rstrip())
if p.stdout:
stdout_thread.join()

if check_call and p.returncode != 0:
raise subprocess.CalledProcessError(
Expand Down

0 comments on commit 555046d

Please sign in to comment.