Skip to content

Commit 27a5292

Browse files
miss-islingtonhroncokEclips4
authored
[3.13] GH-118943: Handle races when moving jit_stencils.h (GH-122709)
(cherry picked from commit 44659d3) Co-authored-by: Miro Hrončok <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]>
1 parent 84c8cd0 commit 27a5292

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a possible race condition affecting parallel builds configured with
2+
``--enable-experimental-jit``, in which :exc:`FileNotFoundError` could be caused by
3+
another process already moving ``jit_stencils.h.new`` to ``jit_stencils.h``.

Tools/jit/_targets.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ def build(
221221
file.write("\n")
222222
for line in _writer.dump(stencil_groups):
223223
file.write(f"{line}\n")
224-
jit_stencils_new.replace(jit_stencils)
224+
try:
225+
jit_stencils_new.replace(jit_stencils)
226+
except FileNotFoundError:
227+
# another process probably already moved the file
228+
if not jit_stencils.is_file():
229+
raise
225230
finally:
226231
jit_stencils_new.unlink(missing_ok=True)
227232

0 commit comments

Comments
 (0)