From 0978de2449e5a2c442ac65c7ea219a82172ce063 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sun, 25 May 2025 19:19:29 +0300 Subject: [PATCH] Revert "[3.14] gh-80334: fix multiprocessing.freeze_support for other spawn platforms (GH-134462) (#134619)" This reverts commit 00fd5440f03e55718bad76dbc45725f24744596c. --- Doc/library/multiprocessing.rst | 10 +++++----- Lib/multiprocessing/context.py | 2 +- .../2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst | 2 -- 3 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 6f37930ea80391..6c43d5fe166e2f 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -1081,7 +1081,7 @@ Miscellaneous .. function:: freeze_support() Add support for when a program which uses :mod:`multiprocessing` has been - frozen to produce an executable. (Has been tested with **py2exe**, + frozen to produce a Windows executable. (Has been tested with **py2exe**, **PyInstaller** and **cx_Freeze**.) One needs to call this function straight after the ``if __name__ == @@ -1099,10 +1099,10 @@ Miscellaneous If the ``freeze_support()`` line is omitted then trying to run the frozen executable will raise :exc:`RuntimeError`. - Calling ``freeze_support()`` has no effect when the start method is not - *spawn*. In addition, if the module is being run normally by the Python - interpreter (the program has not been frozen), then ``freeze_support()`` - has no effect. + Calling ``freeze_support()`` has no effect when invoked on any operating + system other than Windows. In addition, if the module is being run + normally by the Python interpreter on Windows (the program has not been + frozen), then ``freeze_support()`` has no effect. .. function:: get_all_start_methods() diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py index 051d567d457928..d0a3ad00e53ad8 100644 --- a/Lib/multiprocessing/context.py +++ b/Lib/multiprocessing/context.py @@ -145,7 +145,7 @@ def freeze_support(self): '''Check whether this is a fake forked process in a frozen executable. If so then run code specified by commandline and exit. ''' - if self.get_start_method() == 'spawn' and getattr(sys, 'frozen', False): + if sys.platform == 'win32' and getattr(sys, 'frozen', False): from .spawn import freeze_support freeze_support() diff --git a/Misc/NEWS.d/next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst b/Misc/NEWS.d/next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst deleted file mode 100644 index 228429516db416..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`multiprocessing.freeze_support` now checks for work on any "spawn" -start method platform rather than only on Windows.