From c684b01cfe625532c34978662405ab068888549d Mon Sep 17 00:00:00 2001 From: kovan Date: Sun, 8 Feb 2026 21:43:10 +0100 Subject: [PATCH] gh-140814: Fix call order in multiprocessing example Move set_start_method() before freeze_support() in the "Safe importing of main module" example. freeze_support() internally accesses the start method context, which causes a subsequent set_start_method() to raise RuntimeError('context has already been set'). Co-Authored-By: Claude Opus 4.6 --- Doc/library/multiprocessing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index d3baf2d760f615..2cfacbc222e054 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -3238,8 +3238,8 @@ Safe importing of main module print('hello') if __name__ == '__main__': - freeze_support() set_start_method('spawn') + freeze_support() p = Process(target=foo) p.start()