多进程

查看pid

from multiprocessing import Process
import time,os

def task():
    print('%s is running,parent id is <%s>' %(os.getpid(),os.getppid()))
    time.sleep(3)
    print('%s is done,parent id is <%s>' %(os.getpid(),os.getppid()))

if __name__ == '__main__':
    p=Process(target=task,)
    p.start()

    print('',os.getpid(),os.getppid())


# 主 8432 12568
# 4468 is running,parent id is <8432>
# 4468 is done,parent id is <8432>

# >tasklist | findstr pycharm
# pycharm64.exe                12568 Console                    3    757,480 K
View Code
原文地址:https://www.cnblogs.com/wenyule/p/9123327.html