GH-118943: Fix a race condition when generating jit_stencils.h#118957
GH-118943: Fix a race condition when generating jit_stencils.h#118957brandtbucher merged 5 commits intopython:mainfrom
jit_stencils.h#118957Conversation
savannahostrowski
left a comment
There was a problem hiding this comment.
Overall, this LGTM. Just one comment.
hroncok
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.hfile. 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.cmay be built with an incompletejit_stencils.h#118943