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, )
    10. p.start()
    11. print(p.is_alive())
    12. p.join()
    13. print('主', os.getpid(), os.getppid())
    14. print(p.pid)
    15. print(p.is_alive())

    进程阻塞.gif