1. # 了解:is_alive
    2. from multiprocessing import Process
    3. import time, os
    4. def task():
    5. print('%s is running,parent id is <%s>' % (os.getpid(), os.getppid()))
    6. time.sleep(3)
    7. print('%s is done,parent id is <%s>' % (os.getpid(), os.getppid()))
    8. if __name__ == '__main__':
    9. p = Process(target=task, name='sub——Precsss')
    10. p.start()
    11. p.terminate() # 结束需要时间,所以time.sleep(3)
    12. time.sleep(3)
    13. print(p.is_alive())
    14. print('主')
    15. print(p.name)

    进程阻塞.gif