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.
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: lock shared cache directory #1888
fix: lock shared cache directory #1888
Changes from 1 commit
2d9d3df
7e134dd
325e741
12f6665
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This stops using the fake filesystem and uses the real FS. I think it was a mistake for me to use pyfakefs for integration tests.
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.
These changes are to deal with the change from using pyfakefs to using a real path.
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.
I'm confused here - why isn't the cache visible? Did the call to
_maybe_lock_cache()
insideprovider.instance()
fall into theexcept OSError:
codepath?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.
Yes, because we run
_maybe_lock_cache
on line 36. Looking back I realise I named the function for the success case and tested for the failure case. I'll fix thatThere 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.
this is surprising to me because I thought
flock()
was per-process, so a process trying to flock a file it already holds would be a noopIf this isn't the case, what happens if we do multiple consecutive managed builds? Like a build plan with multiple entries
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.
You're right! I wasn't checking for that properly, either. However, it's not quite per-process either. It's per file descriptor, so the same process can't lock the same path in two places if it's got the file open separately twice. (This also requires making two separate
Path
objects, aspathlib
will cache the file descriptor for the same object, as I learnt the hard way.)I've updated it now with a much better lock and test.