View the process id of the method

multiprocessing from Import Process 
Import Time
Import OS
DEF RUN ():
Print ( '% S Runing with IS, IS parent <% S>'% (os.getpid () , os.getppid ()))
the time.sleep ( . 3)
Print ( '% S IS Down, parent IS <% S>'% (os.getpid () , os.getppid ()))
IF the __name__ == '__main__':
P = Process ( target = RUN)
p.start ()
Print ( 'primary' , os.getppid ())
# os.getppid () to view the main process id
# os.getpid () to view the child process id

Guess you like

Origin www.cnblogs.com/yuexijun/p/11515055.html