系统相关
首页 > 系统相关> > python复习笔记04_多进程

python复习笔记04_多进程

作者:互联网

 

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()  

标签:复习,04,start,python,pid,process,getpid,print,os
来源: https://blog.csdn.net/u011331731/article/details/89227081