From 1814cdadd14fdcb9d69a95c43f21c39b68d48b2b Mon Sep 17 00:00:00 2001 From: Eddy Mulyono Date: Wed, 21 May 2025 14:58:49 -0400 Subject: [PATCH 1/4] gh-80334: Doc/library/multiprocessing.rst: freeze_support: Change to specify spawn method instead of platform --- Doc/library/multiprocessing.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 80e33c4a1df015..6639321b285bb5 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 a Windows executable. (Has been tested with **py2exe**, + frozen to produce an executable. (Has been tested with **py2exe**, **PyInstaller** and **cx_Freeze**.) One needs to call this function straight after the ``if __name__ == @@ -1099,9 +1099,8 @@ 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 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 + 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. .. function:: get_all_start_methods() From 8d77d8e9875cec8181c503cd767c7cda132d1075 Mon Sep 17 00:00:00 2001 From: Eddy Mulyono Date: Thu, 22 May 2025 15:12:41 -0400 Subject: [PATCH 2/4] Doc/library/multiprocessing.rst: freeze_support: Change to wrap at 80 chars --- Doc/library/multiprocessing.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 6639321b285bb5..fc3c1134f97c85 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -1099,9 +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 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. .. function:: get_all_start_methods() From 2ffa8601eef0de60c468a430bb37bc64133175a4 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 24 May 2025 03:07:44 +0000 Subject: [PATCH 3/4] gh-80334: Have multiprocessing.freeze_support() enable on spawn, not just win32. --- Lib/multiprocessing/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py index d0a3ad00e53ad8..051d567d457928 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 sys.platform == 'win32' and getattr(sys, 'frozen', False): + if self.get_start_method() == 'spawn' and getattr(sys, 'frozen', False): from .spawn import freeze_support freeze_support() From da15203c8812310cc7a3a77b3d99843bc8ce50eb Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 24 May 2025 03:10:38 +0000 Subject: [PATCH 4/4] NEWS --- .../next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst 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 new file mode 100644 index 00000000000000..228429516db416 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-05-24-03-10-36.gh-issue-80334.z21cMa.rst @@ -0,0 +1,2 @@ +:func:`multiprocessing.freeze_support` now checks for work on any "spawn" +start method platform rather than only on Windows. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy