Skip to content
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

Atomically write cache files #674

Merged
merged 1 commit into from
Jan 19, 2019
Merged

Atomically write cache files #674

merged 1 commit into from
Jan 19, 2019

Conversation

asottile
Copy link
Contributor

Resolves #673

Before:

$ find x -name "*.py" | xargs -P8 --replace bash -c 'rm -rf ~/Library/Caches/black && black -q {}'
error: cannot format x/57.py: Ran out of input
error: cannot format x/77.py: Ran out of input
$ find x -name "*.py" | xargs -P8 --replace bash -c 'rm -rf ~/Library/Caches/black && black -q {}'
error: cannot format x/75.py: Ran out of input
error: cannot format x/85.py: Ran out of input
error: cannot format x/73.py: Ran out of input
$ find x -name "*.py" | xargs -P8 --replace bash -c 'rm -rf ~/Library/Caches/black && black -q {}'
error: cannot format x/31.py: Ran out of input
error: cannot format x/35.py: Ran out of input
error: cannot format x/30.py: Ran out of input
error: cannot format x/79.py: Ran out of input
error: cannot format x/49.py: Ran out of input
error: cannot format x/23.py: Ran out of input

After:

$ find x -name "*.py" | xargs -P8 --replace bash -c 'rm -rf ~/Library/Caches/black && black -q {}'
$ find x -name "*.py" | xargs -P8 --replace bash -c 'rm -rf ~/Library/Caches/black && black -q {}'
$ find x -name "*.py" | xargs -P8 --replace bash -c 'rm -rf ~/Library/Caches/black && black -q {}'

@coveralls
Copy link

coveralls commented Jan 18, 2019

Pull Request Test Coverage Report for Build 867

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 91.587%

Files with Coverage Reduction New Missed Lines %
black.py 2 94.66%
Totals Coverage Status
Change from base Build 865: -0.06%
Covered Lines: 2787
Relevant Lines: 3043

💛 - Coveralls

@JelleZijlstra
Copy link
Collaborator

I suppose there's still a race condition, but now the effect is just that we lose some updates, instead of corrupting the cache or whatever it did before.

@JelleZijlstra JelleZijlstra merged commit 4d31072 into psf:master Jan 19, 2019
@JelleZijlstra
Copy link
Collaborator

Thanks for your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants