进程ID


from multiprocessing import Process
import os


def info(title):
print(title)
print('module name:', __name__)
print('parent process:', os.getppid())
print('process id:', os.getpid())
print("\n\n")


def f(name):
info('\033[31;1mcalled from child process function f\033[0m')
print('hello', name)

if __name__ == '__main__':
info('\033[32;1mmain process line\033[0m')
p = Process(target=f, args=('bob',))
p.start()
# p.join()


main process line
module name: __main__
parent process: 2728
process id: 25524

 

called from child process function f
module name: __mp_main__
parent process: 25524
process id: 14060

 

hello bob

posted @ 2018-11-18 21:29  rongye  阅读(227)  评论(0编辑  收藏  举报