-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
GH-118943: Fix a race condition when generating jit_stencils.h
#118957
Conversation
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.
Overall, this LGTM. Just one comment.
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 change makes perfect sense and should fix the problem. Hard to test due to the nature of the issue, hence untested.
One question though (and one optional suggestion).
file.write(digest) | ||
if comment: | ||
file.write(f"// {comment}\n\n") | ||
file.write("") |
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.
Not entirely sure what was the purpose of this line, but it is no longer there. I guess it did nothing, correct?
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.
Nice catch. Yeah, I think this was originally intended to write a newline, but it was really doing nothing. But I think we do want to add a newline whether or not there's a comment, so I'll move one of them from the comment line to here.
Tools/jit/_targets.py
Outdated
file.write(f"{line}\n") | ||
jit_stencils_new.replace(jit_stencils) | ||
finally: | ||
jit_stencils_new.unlink(True) |
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 had to guess (and look up) what the boolean stands for. Would you mind using a keyword argument instead?
jit_stencils_new.unlink(True) | |
jit_stencils_new.unlink(missing_ok=True) |
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.
Yep, good suggestion.
Thanks @brandtbucher for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…ythonGH-118957) (cherry picked from commit 4702b7b) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
GH-119101 is a backport of this pull request to the 3.13 branch. |
Write to a temporary file first, then rename it to the intended
jit_stencils.h
file. This keeps other build steps from assuming that the file has been successfully generated when it's still in the process of being written.CC: @savannahostrowski
jit.c
may be built with an incompletejit_stencils.h
#118943