Skip to content

Regression in multiprocessing.set_start_method introduced in Python 3.13.4 #135726

Open
@marcelotduarte

Description

@marcelotduarte

Bug report

Bug description:

PR #134462 (GH-80334) breaks set_start_method for use in Python (not frozen) and also breaks it for cx_Freeze.
A simple sample using 'spaw', but also breaks with 'fork' or 'forkserver':

import multiprocessing

def foo(q):
    q.put("Hello from cx_Freeze")

if __name__ == "__main__":
    multiprocessing.freeze_support()
    multiprocessing.set_start_method('spawn')
    q = multiprocessing.SimpleQueue()
    p = multiprocessing.Process(target=foo, args=(q,))
    p.start()
    print(q.get())
    p.join()

This sample worked before in windows and linux for python 3.9 until python 3.13.3.
For cx_Freeze I made a temporary fix.

I suspect that a correct fix is change the line 148 from:
if self.get_start_method() == 'spawn' and getattr(sys, 'frozen', False):
to a simple:
if getattr(sys, 'frozen', False):

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesstdlibPython modules in the Lib dirtopic-multiprocessingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions