]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] GH-118943: Handle races when moving jit_stencils.h (GH-122709)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 8 Aug 2024 20:37:49 +0000 (22:37 +0200)
committerGitHub <noreply@github.com>
Thu, 8 Aug 2024 20:37:49 +0000 (13:37 -0700)
(cherry picked from commit 44659d392751f0161a0f958fec39ad013da45427)

Co-authored-by: Miro HronĨok <miro@hroncok.cz>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Misc/NEWS.d/next/Build/2024-06-18-15-28-25.gh-issue-118943.aie7nn.rst [new file with mode: 0644]
Tools/jit/_targets.py

diff --git a/Misc/NEWS.d/next/Build/2024-06-18-15-28-25.gh-issue-118943.aie7nn.rst b/Misc/NEWS.d/next/Build/2024-06-18-15-28-25.gh-issue-118943.aie7nn.rst
new file mode 100644 (file)
index 0000000..997c990
--- /dev/null
@@ -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``.
index 5604c429bcf8ad8f29f1ea0b03aab48ab2d93353..73d10a128756eb1cb52fead6a528d1ef91d835e8 100644 (file)
@@ -221,7 +221,12 @@ class _Target(typing.Generic[_S, _R]):
                 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)