Python 进程 Manager
from multiprocessing import Manager,Process
import os
def f(d,l):
d[os.getpid()]=os.getpid()
l.append(os.getpid())
print(l)
if __name__=="__main__":
with Manager() as manager:
d=manager.dict()
l=manager.list(range(5))
p_list=[]
for i in range (10):
p=Process(target=f,args=(d,l))
p_list.append(p)
p.start()
for res in p_list:
res.join()
print(d)
print(l)