-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Issue 1120 (Cleaning up tmpdir's) #6253
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f9d5127
Register cleanup_numbered_dir for atexit before the cleanup for locks…
bitmuster 3d5d0ac
Add comments to clarify directory cleanup
bitmuster 0213740
Remove obsolete cleanup at program start
bitmuster 9439e07
Linting autoformat
bitmuster 7dee7fc
Add changelog entry
bitmuster 3e07134
Update AUTHORS file
bitmuster 5eb46e3
Move at_exit registration outside numbered dir loop
caitelatte 137a2a7
Add caitlin to the AUTHORS
caitelatte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix issue where directories from ``tmpdir`` are not removed properly when | ||
multiple instances of pytest are running in parallel. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
p.stat().st_mtime
, this could just betime.time()
(which you might need to import)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code as it is hoere cant hope to work (as p is not defined up there)
ensuring the lock time-out is considered relative to the created folder is critical (as it ensures relative timing correctness)
as far as i can tell the atexit registration can only be done sanely in the else clasuse where we did the cal lbeffore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something we MUST check is if based on the atexit order this allows the folder of the current process to be cleaned up alongside other folders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review folks. I didn't notice the relationship to the
p
folder at the time so I'm sorry for missing that!@RonnyPfannschmidt could you please expand on the relative timing correctness using the successful folder's creation time results in? I thought that using the time at the beginning of the function would be good enough.
If we move the
register
back into theelse:
clause of the try/except block, I suspect that it may not always be called if folder creation didn't succeed at all, so wouldn't be registered to clean up older folders. What if it goes into afinally:
clause or at the end of the for loop, so that it always gets called regardless of success or failure to create a folder? This would still need to remove the reliance onp.stat().st_mtime
as it may not have been created.Regarding atexit order, the
register_cleanup_lock_removal(lock_path)
line registers its own atexit cleanup on a lock on p usingregister_cleanup_lock_removal(p)
. We should move the cleanup_numbered_dir registration after the register_cleanup_lock_removal in that case, so that it can run after the lock should have been released.There's some complex relationships between lock files here so further conversation and feedback would be appreciated 😸
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrt ensuring the timing is relative to the process, this simply accounts for the possibility of process suspension between setting up the atexit handler and the creation.
it is a rather uncommon/unlikely occurrence
as for not running clean-up if a folder couldn't be made, that seems acceptable to me
the relationship between the lock in p and the folder clean-up is easy to miss, as its not explicit in code, but implicit in context, i just barely noted the detail after a gut feeling and reading the code as well as surrounding code a number of times before it clicked