Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ Pedro Algarvio
Philipp Loose
Pieter Mulder
Piotr Banaszkiewicz
Piotr Helm
Prashant Anand
Pulkit Goyal
Punyashloka Biswal
Expand Down
1 change: 1 addition & 0 deletions changelog/1120.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue where directories from tmpdir are not removed properly when multiple instances of pytest are running in parallel.
12 changes: 7 additions & 5 deletions src/_pytest/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@ def make_numbered_dir_with_cleanup(
e = exc
else:
consider_lock_dead_if_created_before = p.stat().st_mtime - lock_timeout
cleanup_numbered_dir(
root=root,
prefix=prefix,
keep=keep,
consider_lock_dead_if_created_before=consider_lock_dead_if_created_before,
# Register a cleanup for program exit
atexit.register(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might still fail because some pytest process will finish before others so they might still step in each others toes, I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean one of the race condition cases mentioned in maybe_delete_a_numbered_dir()? I thought try_cleanup() invoked from cleanup_numbered_dir() is preventing from such case or at least we have some guarantees - based on comments from maybe_delete_a_numbered_dir().

cleanup_numbered_dir,
root,
prefix,
keep,
consider_lock_dead_if_created_before,
)
return p
assert e is not None
Expand Down