标签:from llb foo 进程 for name ret close python
from multiprocessing import Process,Pool
import time,os
def Foo(i):
time.sleep(2)
print("in the Proess ",os.getpid())
return i
def Bar(arg):
print("-->exec done:",arg,os.getpid())
if __name__ == "__main__":
print("in the main process",os.getpid())
pool = Pool(3)
for i in range(10):
pool.apply_async(func=Foo,args=(i,),callback=Bar)
#pool.apply(func=Foo,args=(i,))
print("end")
pool.close()
pool.join()
标签:from llb foo 进程 for name ret close python
原文地址:http://www.cnblogs.com/xiesongyou/p/7749309.html