标签:spl async art join() roc data mail one dem
1 #!/usr/bin/env python3 2 # -*- coding: utf-8 -*- 3 # @Time : 2019/3/28 11:58 4 # @Author : suwy 5 # @Email : suwy@cndatacom.com 6 # @File : mulitprocess_demo.py 7 # @Software: PyCharm 8 9 from multiprocessing import Process,Pool 10 import multiprocessing 11 import os 12 13 def run(name): 14 print("{} pid:{}".format(name,os.getpid())) 15 16 def run1(data): 17 print("{} say {} pid:{}".format(data[0],data[1],os.getpid())) 18 19 run("main") 20 pro = Process(target=run,args=("process-1",)) 21 pro.start() 22 pro.join() 23 24 p = Pool(2) 25 for i in range(10): 26 p.apply_async(run,args=(i,)) 27 p.close() 28 p.join() 29 print(multiprocessing.cpu_count()) 30 map = Pool(2) 31 map.map_async(run1,[("suwy","lkk"),("roc","kdjf"),("swy","dfkj"),("loli","dsfd"),("venix","hello")]) 32 map.close() 33 map.join()
标签:spl async art join() roc data mail one dem
原文地址:https://www.cnblogs.com/swyroc/p/10678512.html