python复习笔记04_多进程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011331731/article/details/89227081

 

pid = os.fork()  
if pid == 0:  
    print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))  
else:  
    print('I (%s) just created a child process (%s).' % (os.getpid(), pid))  
p = Process(target=run_proc, args=('test',))  
print('Child process will start.')  
p.start()  
p.join()  
  
p = Pool(4)  
for i in range(5):  
	p.apply_async(long_time_task, args=(i,))  
print('Waiting for all subprocesses done...')  
p.close()  
p.join()  

猜你喜欢

转载自blog.csdn.net/u011331731/article/details/89227081
04_
今日推荐