-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
执行多进程相关代码,无限启动进程, python环境为 3.11.5, 以下为PyStand.py内容:
if __name__ == "__main__":
import multiprocessing as mp
mp.set_start_method("spawn", force=True)
mp.freeze_support()
from concurrent.futures import ProcessPoolExecutor
import os
print("主进程 PID:", os.getpid())
def worker(x):
return x * x
with ProcessPoolExecutor(4) as pool:
print("结果:", list(pool.map(worker, range(20))))
Metadata
Metadata
Assignees
Labels
No labels