Skip to content

Commit

Permalink
00429: pythonGH-118943: Fix another race condition when generating ji…
Browse files Browse the repository at this point in the history
…t_stencils.h

Another process might have already moved jit_stencils.h.new
  • Loading branch information
hroncok committed Aug 6, 2024
1 parent 906f5d2 commit d9150a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a possible race condition affecting parallel builds configured with
``--enable-experimental-jit``, in which :exc:`FileNotFoundError` could be caused by
another process already moving ``jit_stencils.h.new`` to ``jit_stencils.h``.
7 changes: 6 additions & 1 deletion Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ def build(
file.write("\n")
for line in _writer.dump(stencil_groups):
file.write(f"{line}\n")
jit_stencils_new.replace(jit_stencils)
try:
jit_stencils_new.replace(jit_stencils)
except FileNotFoundError:
# another process probably already moved the file
if not jit_stencils.is_file():
raise
finally:
jit_stencils_new.unlink(missing_ok=True)

Expand Down

0 comments on commit d9150a2

Please sign in to comment.