简单粗暴的方法
| 12
 3
 4
 5
 6
 7
 
 | f1 = Process(target=func1,args=(q1res,))f2 = Process(target=func2,args=(q2res,))
 
 f1.start()
 f2.start()
 f1.join()
 f2.join()
 
 | 
简单处理多进程
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 
 | ps=[]for i in [fanca, funcb]
 p=Process(target=i)
 ps.append(p)
 
 for i in range(2):
 ps[i].start()
 
 for i in range(2):
 ps[i].join()
 
 | 
使用进程池处理多进程
| 12
 3
 4
 5
 
 | ps = Pool(3)for p in [write_showDF, write_clickDF, write_textLinks]:
 ps.apply(p)
 ps.close()
 ps.join()
 
 | 
进程间通信
以第一种形式,且子进程间无交互为例
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 
 | q1res = mp.Queue()q2res = mp.Queue()
 f1 = Process(target=func1,args=(q1res,))
 f2 = Process(target=func2,args=(q2res,))
 
 f1.start()
 f2.start()
 f1.join()
 f2.join()
 rec_cec_df,norm_cec_df=q1res.get(),q2res.get()
 
 |