Skip to content

Commit c684b01

Browse files
kovanclaude
andcommitted
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 <noreply@anthropic.com>
1 parent cfeede8 commit c684b01

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3238,8 +3238,8 @@ Safe importing of main module
32383238
print('hello')
32393239

32403240
if __name__ == '__main__':
3241-
freeze_support()
32423241
set_start_method('spawn')
3242+
freeze_support()
32433243
p = Process(target=foo)
32443244
p.start()
32453245

0 commit comments

Comments
 (0)