python 多进程简单调用

python 多进程简

#!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:leo
# datetime:2019/5/28 10:03
# software: PyCharm
from multiprocessing import Process
import time
import os
def going(n):
    print("this is process %s"% (n,))
    print(os.getpid())#获取进程的id
    print(os.getppid())#获取父进程的id
    time.sleep(2)
if __name__=="__main__":
    for i in range(5):
        p=Process(target=going,args=(i,))
        p.start()
        #p.join()

猜你喜欢

转载自www.cnblogs.com/leo0362/p/10935529.html