Skip to content

Cross-implementation support of multiprocessing module #131656

@pypy66

Description

@pypy66

Feature or enhancement

Proposal:

When I launch a subprocess from other implementations, such as PyPy, or other Python versions including 3.8, the sys.path in those interpreters unexpectedly inherits from the 3.13 parent process, which is incorrect and leads to import errors.

import sys,multiprocessing

def f(n):
    return sum(range(n))

def worker(n,result):
    result.value=f(n)
    print(f"Done from {sys.executable}")

if __name__=="__main__":
    n = 100000000 # Attempt to calculate it from PyPy
    multiprocessing.set_executable(r"D:\Python\pypy3.10-v7.3.17-win64\python.exe")

    result = multiprocessing.Value('i', 0)

    process = multiprocessing.Process(target=worker, args=(n, result))
    process.start()
    process.join()

    assert result.value != 0, "An error may have occurred in the subprocess"
    print(f"Result from f({n}): {result.value}")

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions