8000 gh-80334: fix multiprocessing.freeze_support for other spawn platform… · python/cpython@80284b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 80284b5

Browse files
eddymulgpshead
andauthored
gh-80334: fix multiprocessing.freeze_support for other spawn platforms (GH-134462)
Doc/library/multiprocessing.rst: freeze_support: Change to specify spawn method instead of platform Have multiprocessing.freeze_support() enable on spawn, not just win32. --------- Co-authored-by: Gregory P. Smith <greg@krypto.org>
1 parent 74a9c60 commit 80284b5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Doc/library/multiprocessing.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ Miscellaneous
10811081
.. function:: freeze_support()
10821082

10831083
Add support for when a program which uses :mod:`multiprocessing` has been
1084-
frozen to produce a Windows executable. (Has been tested with **py2exe**,
1084+
frozen to produce an executable. (Has been tested with **py2exe**,
10851085
**PyInstaller** and **cx_Freeze**.)
10861086

10871087
One needs to call this function straight after the ``if __name__ ==
@@ -1099,10 +1099,10 @@ Miscellaneous
10991099
If the ``freeze_support()`` line is omitted then trying to run the frozen
11001100
executable will raise :exc:`RuntimeError`.
11011101

1102-
Calling ``freeze_support()`` has no effect when invoked on any operating
1103-
system other than Windows. In addition, if the module is being run
1104-
normally by the Python interpreter on Windows (the program has not been
1105-
frozen), then ``freeze_support()`` has no effect.
1102+
Calling ``freeze_support()`` has no effect when the start method is not
1103+
*spawn*. In addition, if the module is being run normally by the Python
1104+
interpreter (the program has not been frozen), then ``freeze_support()``
1105+
has no effect.
11061106

11071107
.. function:: get_all_start_methods()
11081108

Lib/multiprocessing/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def freeze_support(self):
145145
'''Check whether this is a fake forked process in a frozen executable.
146146
If so then run code specified by commandline and exit.
147147
'''
148-
if sys.platform == 'win32' and getattr(sys, 'frozen', False):
148+
if self.get_start_method() == 'spawn' and getattr(sys, 'frozen', False):
149149
from .spawn import freeze_support
150150
freeze_support()
151151

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:func:`multiprocessing.freeze_support` now checks for work on any "spawn"
2+
start method platform rather than only on Windows.

0 commit comments

Comments
 (0)
0