Skip to content

Commit 409b946

Browse files
committed
Explicitly close down the existing PEP 517 frontend when resetting root.
1 parent 79f3ec6 commit 409b946

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/tox/tox_env/python/virtual_env/package/pyproject.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,14 @@ def root(self) -> Path:
118118

119119
@root.setter
120120
def root(self, value: Path) -> None:
121-
# NOTE(vytas): Recreating the frontend with a new root will orphan the
122-
# current frontend.backend_executor, if any, making tox hang upon
123-
# exit waiting for its threads and subprocesses (#3512).
124-
#
125-
# Here, we partially work around the issue by only resetting the root
126-
# when it has actually changed:
127-
if self._root != value:
128-
self._root = value
129-
self._frontend_ = None # force recreating the frontend with new root
121+
# Recreating the frontend with a new root would orphan the current frontend.backend_executor, if any, making tox
122+
# hang upon exit waiting for its threads and subprocesses (#3512).
123+
# Therefore, we make sure to close the existing back-end executor in the case of an existing PEP 517 frontend.
124+
if self._frontend is not None:
125+
self._frontend.backend_executor.close()
126+
127+
self._root = value
128+
self._frontend_ = None # force recreating the frontend with new root
130129

131130
@staticmethod
132131
def id() -> str:

0 commit comments

Comments
 (0)