Skip to content

Cannot use 'multiprocessing' #100241

Closed
Closed
@670133189

Description

@670133189

Python 3.10.9
MacOS M2 Ventura@13.1

Cannot use 'multiprocessing'.

Prompt: ValueError:<multiprocessing. pool. ApplyResult object at 0x1273d5ff0>not ready

Code reference: https://docs.python.org/zh-cn/3.10/library/multiprocessing.html?highlight=multiprocessing#module -multiprocessing.pool

from multiprocessing import Pool
import time

def f(x):
    return x*x

if __name__ == '__main__':
    with Pool(processes=4) as pool:         # start 4 worker processes
        result = pool.apply_async(f, (10,)) # evaluate "f(10)" asynchronously in a single process
        print(result.get(timeout=1))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions