Use a lock file to avoid exceptions due to concurrenct symlink creation#2851
Closed
stefanberger wants to merge 1 commit intotheupdateframework:developfrom
Closed
Use a lock file to avoid exceptions due to concurrenct symlink creation#2851stefanberger wants to merge 1 commit intotheupdateframework:developfrom
stefanberger wants to merge 1 commit intotheupdateframework:developfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We have seen exceptions being raised from _update_root_symlink() on the level of the sigstore-python library when multiple concurrent threads were creating symlinks in this function with the same symlink name (in a test environment running tests concurrently). To avoid this issue, have each thread open a lock file and create an exclusive lock on it to serialize the access to the removal and creation of the symlink.
The reproducer for this issue, that should be run in 2 or more python interpreters concurrently, looks like this:
Use fcntl.lockf-based locking for Linux and Mac and a different implementation on Windows. The source originally comes from a discussion on stockoverflow (link below).
Resolves: #2836
Link: https://stackoverflow.com/questions/489861/locking-a-file-in-python
Description of the changes being introduced by the pull request:
Fixes #2836