-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix a race condition in simultaneous poetry installations updating the cache #6186
Conversation
Makes sense to me. I just wonder if it's wise to import a helper function from I don't know how to test this either. Maybe, we can go without a test here. @neersighted What do you think? |
I'm wondering if #6471 is the better solution -- I agree that we should yoink |
#6471 and this are independent fixes, it would make perfect sense to merge them both (#6471 relates to files owned by cachecontrol's filecache, this one relates to a file written by poetry regardless of whether caching is enabled or not) Edit: rather than the race condition with multiple poetry processes that zweger describes, I bet a more common bug that this fixes is: user hits Ctrl-C while part way through a download. Currently this leaves a half-downloaded file in place, if I understand correctly this should stop that from happening. |
Fair enough, and good point |
Hi, thanks for the feedback. I've updated this PR to include |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
If one poetry installation is writing to the cache while a second installer is attempting to read that cache file, the second installation will fail because the in-flight cache file is invalid while it is still being written to by the first process.
This PR resolves this issue by having Poetry write to a temporary file in the cache directory first, and then rename the file after it's written, which is ~atomic.
Pull Request Check List
Resolves: #5142
I'm not sure how to test this change, as the conditions which cause this bug to appear are a little hard to reproduce.