-
-
Notifications
You must be signed in to change notification settings - Fork 375
#272 Fix race condition in DirectoryStore #318
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9f89844
#272 fix race condition to make folders in directory store
jmswaney 5b36916
#272 remove FileNotFoundError for python 2 support
jmswaney 37d6ec4
Change OSError to KeyError to make tests pass
jmswaney b87b702
Only catch `OSError` if its `errno` equal `EEXIST`
jakirkham fd82a75
Merge 'zarr-developers/master' into 'jmswaney/master'
jakirkham aab8b39
Drop generic `Exception` case in `DirectoryStore`
jakirkham 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
Binary file not shown.
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 @@ | ||
| bar |
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.
Hmm...so this
exceptcase doesn't catch it?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
except Exceptionblock was catching it before, but it was just throwingKeyErrorinstead--so my code would still error out. The block that I added only raisesKeyErrorif the folder doesn't exist already. This way, workers can go on with their business if the folder already exists.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.
Should we then drop the
except Exceptionentirely and only useexcept OSError? It seems bad to mask other errors by raisingKeyErrorinstead.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 think that's a good idea. I wasn't sure about that part so I left it, but I'm not sure what other exceptions you can even expect from
os.makedirs. If you gotOSErrorbecause of permissions or something else that prevented making the folder, then the block that I added would raiseKeyErroranyway.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.
Good point. We can improve this a bit then by checking the
errnoof theOSError. Namely if we finde.errno == errno.EEXIST, then we know this is aFileExistsError. If it's any othererrno, we can just re-raise the exception as is.ref: https://docs.python.org/3/library/exceptions.html#FileExistsError
ref: https://docs.python.org/3/library/errno.html#errno.EEXIST
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.
Have taken the liberty of pushing a commit to your branch using the
errnobit. Please let me know what you think.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.
That makes sense. Honestly this is an orthogonal issue. So we need not address it here. Will raise an issue to follow-up on this after.
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.
Went ahead and dropped the generic exception case as it didn't seem to be covered. Happy to revisit if we figure out it was needed for some reason.