📜  显示所涉及的各个进程 ID - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:12.298000             🧑  作者: Mango

代码示例1
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())

def f(name):
    info('function f')
    print('hello', name)

if __name__ == '__main__':
    info('main line')
    p = Process(target=f, args=('bob',))
    p.start()
    p.join()