查看进程id的方法

from multiprocessing import Process
import time
import os
def 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

猜你喜欢

转载自www.cnblogs.com/yuexijun/p/11515055.html