from multiprocessing import Processimport timeimport osdef run(): print(‘%s is runing,parent is <%s>‘%(os.getpid(), os.getppid())) time.sleep(3) print(‘%s is down, parent is <%s>‘%(os.getpid(), os.getppid()))if __name__ ==‘__main__‘: p = Process(target=run) p.start() print(‘主‘,os.getppid())#os.getppid() 查看主进程的id#os.getpid() 查看子进程的id
原文地址:https://www.cnblogs.com/yuexijun/p/11515055.html
时间: 2024-10-26 00:29:00