标签:art main target python pipe 交互 roc ssi pytho
1.管道使用‘‘‘
管道Pipe
‘‘‘
from multiprocessing import Process,Pipe
def f(conn):
conn.send(‘child message‘)
conn.close()
if __name__==‘__main__‘:
parent_conn,child_conn=Pipe()
p=Process(target=f,args=(child_conn,))
p.start()
print(parent_conn.recv())
p.join()
2.Manage
from multiprocessing import Process,Manager
import os
def f(d,l):
d[1]=‘1‘
d[‘2‘]=2
l.append(os.getpid())
if __name__=="__main__":
manage_data=Manager()
d=manage_data.dict()
l=manage_data.list()
p_list=[]
for i in range(10):
p = Process(target=f, args=(d, l))
p.start()
p_list.append(p)
for res in p_list:
res.join()
print(d)
print(l)
>>:
{1: ‘1‘, ‘2‘: 2}
[2472, 7972, 9760, 5328, 5488, 12316, 6780, 12592, 6676, 6408]
标签:art main target python pipe 交互 roc ssi pytho
原文地址:http://blog.51cto.com/13803166/2140182