mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
[3.13] GH-118943: Handle races when moving jit_stencils.h (GH-122709)
(cherry picked from commit 44659d3927
)
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
parent
84c8cd0f3d
commit
27a5292774
2 changed files with 9 additions and 1 deletions
|
@ -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``.
|
|
@ -221,7 +221,12 @@ class _Target(typing.Generic[_S, _R]):
|
||||||
file.write("\n")
|
file.write("\n")
|
||||||
for line in _writer.dump(stencil_groups):
|
for line in _writer.dump(stencil_groups):
|
||||||
file.write(f"{line}\n")
|
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:
|
finally:
|
||||||
jit_stencils_new.unlink(missing_ok=True)
|
jit_stencils_new.unlink(missing_ok=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue