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

FIX: be careful about communicating with subprocess #27785

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
# 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 finalize_latex(latex):
latex.kill()
latex.communicate()
try:
latex.communicate()
except RuntimeError:
latex.wait()

Check warning on line 281 in lib/matplotlib/backends/backend_pgf.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/backends/backend_pgf.py#L280-L281

Added lines #L280 - L281 were not covered by tests

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