Skip to content

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

Closed
PriyansuMaurya wants to merge 1 commit into
tox-dev:mainfrom
PriyansuMaurya:test/isolated-dirs-fresh-processes
Closed

PriyansuMaurya wants to merge 1 commit into
tox-dev:mainfrom
PriyansuMaurya:test/isolated-dirs-fresh-processes

Conversation

@PriyansuMaurya

@PriyansuMaurya PriyansuMaurya commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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.

Add an executable process-pool example and a spawned-process test covering independent child paths, explicit child isolation, file placement and restoration.
@gaborbernat gaborbernat added the documentation Improvements or additions to documentation label Nov 27, 2026
@gaborbernat gaborbernat changed the title Document and test directory isolation in spawned workers 📝 docs(testing): show directory isolation in spawned workers Nov 27, 2026
@gaborbernat

Copy link
Copy Markdown
Member

Closing because this PR does not allow edits by maintainers, so the review fixes could not be pushed here. #754 keeps your commit unchanged and adds the fixes on top. Thanks for the contribution.

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