-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-multiprocessing
Description
Documentation
On Python3.14 page https://docs.python.org/3/library/multiprocessing.html#multiprocessing-programming-forkserver there's an example:
from multiprocessing import Process, freeze_support, set_start_method
def foo():
print('hello')
if __name__ == '__main__':
freeze_support()
set_start_method('spawn')
p = Process(target=foo)
p.start()
My code has:
if __name__ == '__main__':
multiprocessing.freeze_support() # Multiprocessing support for frozen Windows executables
multiprocessing.set_start_method('fork') # The default was changed on POSIX systems from 'fork' to 'forkserver' in Python3.14
But on Ubuntu 25.10 that causes:
Traceback (most recent call last):
File "test.py", line 10705, in <module>
multiprocessing.set_start_method('fork') # The default was changed on POSIX systems from 'fork' to 'forkserver' in Python3.14
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/usr/lib/python3.14/multiprocessing/context.py", line 247, in set_start_method
raise RuntimeError('context has already been set')
RuntimeError: context has already been set
It seems that set_start_method() has to be called BEFORE freeze_support, not AFTER.
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-multiprocessing
Projects
Status
No status
Status
Todo