過程
1.引入模塊
2.實例化Pool
3.向Pool提交任務
4.關閉進程池
5.join進程同步
Demo
from multiprocessing import Pool
import os , time, random
def run_task(name):
pass
if __name__ == '__main__':
p = Pool(process=3)
for i in range(10):
p.apply_async(run_task, args=(str(i), ))
print 'Waiting for all subprocesses done...'
p.close()
p.join()
print 'All subprocesses done.'