Closed
Description
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))