Skip to content

📝 docs(testing): show directory isolation in spawned workers - #754

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:test/isolated-dirs-fresh-processes
Nov 27, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:test/isolated-dirs-fresh-processes

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

platformdirs.testing.isolated_dirs redirects every directory under a root by patching the class in memory. A forked child inherits that patch, but a spawned process starts with fresh module state, so wrapping only the parent leaves a spawned worker on the user's real directories. The how-to guide said spawned children start with the original paths but did not show how to isolate one. 🧪 Once this merges, the guide has a runnable ProcessPoolExecutor example: the parent passes a root as the task argument, the worker enters isolated_dirs with it, and the temporary directory holding the root outlives the pool.

Library behavior stays the same. Isolation remains per process, and each worker opts in with its own root. Concurrent workers that must not share files get separate roots.

Supersedes #751 by @PriyansuMaurya, whose commit is kept unchanged. That fork does not allow maintainer edits, so the review fixes land here on top of it.

PriyansuMaurya and others added 2 commits November 26, 2026 00:40
Add an executable process-pool example and a spawned-process test covering independent child paths, explicit child isolation, file placement and restoration.
@gaborbernat
gaborbernat requested a review from ofek as a code owner November 27, 2026 20:25
@gaborbernat gaborbernat added the documentation Improvements or additions to documentation label Nov 27, 2026
@gaborbernat
gaborbernat merged commit 8d53073 into tox-dev:main Nov 27, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants