Skip to content

Commit

Permalink
Merge pull request #27790 from meeseeksmachine/auto-backport-of-pr-27…
Browse files Browse the repository at this point in the history
…785-on-v3.8.x

Backport PR #27785 on branch v3.8.x (FIX: be careful about communicating with subprocess)
  • Loading branch information
QuLogic committed Feb 14, 2024
2 parents c21a93f + ea407e1 commit 8fff5b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def _setup_latex_process(self, *, expect_reply=True):
# Open LaTeX process for real work; register it for deletion. On
# Windows, we must ensure that the subprocess has quit before being
# able to delete the tmpdir in which it runs; in order to do so, we
# must first `kill()` it, and then `communicate()` with it.
# must first `kill()` it, and then `communicate()` with or `wait()` on
# it.
try:
self.latex = subprocess.Popen(
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
Expand All @@ -274,7 +275,10 @@ def _setup_latex_process(self, *, expect_reply=True):

def finalize_latex(latex):
latex.kill()
latex.communicate()
try:
latex.communicate()
except RuntimeError:
latex.wait()

self._finalize_latex = weakref.finalize(
self, finalize_latex, self.latex)
Expand Down

0 comments on commit 8fff5b1

Please sign in to comment.