标签:编程 def 通过 print code 进程间 操作 ssi app
from multiprocessing import Manager,Process,Lock
def main(dic,lock):
lock.acquire()
dic['count'] -=1
print(dic)
lock.release()
if __name__ == '__main__':
m = Manager()
l = Lock()
dic = m.dict({'count':100}) #主进程中数据提供到子进程去操作
p_lst = []
for i in range(50):
p = Process(target=main,args=(dic,l))
p.start()
p_lst.append(p)
for i in p_lst:i.join()
print('主进程',dic)
标签:编程 def 通过 print code 进程间 操作 ssi app
原文地址:https://www.cnblogs.com/konglinqingfeng/p/9696785.html