Skip to content

Commit 31d115f

Browse files
gpsheadclaude
andcommitted
gh-140814: Add regression test for freeze_support() side effect
Test that freeze_support() does not lock in the default start method, which would prevent a subsequent set_start_method() call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 52738a0 commit 31d115f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5992,6 +5992,20 @@ def test_spawn_dont_set_context(self):
59925992
process.join()
59935993
self.assertIsNone(multiprocessing.get_start_method(allow_none=True))
59945994

5995+
@only_run_in_spawn_testsuite("freeze_support is not start method specific")
5996+
def test_freeze_support_dont_set_context(self):
5997+
# gh-140814: freeze_support() should not set the start method
5998+
# as a side effect, so a later set_start_method() still works.
5999+
multiprocessing.set_start_method(None, force=True)
6000+
try:
6001+
multiprocessing.freeze_support()
6002+
self.assertIsNone(
6003+
multiprocessing.get_start_method(allow_none=True))
6004+
# Should not raise "context has already been set"
6005+
multiprocessing.set_start_method('spawn')
6006+
finally:
6007+
multiprocessing.set_start_method(None, force=True)
6008+
59956009
def test_context_check_module_types(self):
59966010
try:
59976011
ctx = multiprocessing.get_context('forkserver')

0 commit comments

Comments
 (0)