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

Add atomic_directory exclusive mode. #1062

Merged
merged 6 commits into from
Oct 8, 2020
Merged

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Oct 8, 2020

Use this new mode to ensure directories Pex creates that contain Python
code are created exactly once so that the implicit Python bytecode
compilation process is not thwarted by racing directory creation.

Fixes #1051

Use this new mode to ensure directories Pex creates that contain Python
code are created exactly once so that the implicit Python bytecode
compilation process is not thwarted by racing directory creation.

Fixes pex-tool#1051
pex/common.py Outdated
@@ -318,12 +319,16 @@ def cleanup(self):


@contextmanager
def atomic_directory(target_dir, source=None):
def atomic_directory(target_dir, source=None, exclusive=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on not using a default for exclusive, so that call sites must decide what to do? This was a subtle bug - I fear future changes won't realize they need to set exclusive=True, and won't realize they have a race condition until someone hits in the wild.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jsirois jsirois merged commit 0b45ac8 into pex-tool:master Oct 8, 2020
@jsirois jsirois deleted the issues/1051 branch October 8, 2020 19:05
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.

pex creation fails under pants w/ No such file or directory error
2 participants