‘is_alive()’
method return True if process is alive, else False.
from multiprocessing import Process import multiprocessing def print_data(): name = multiprocessing.current_process().name id = multiprocessing.current_process().pid print(name, id) if __name__=="__main__": proc1 = Process(name='process1', target=print_data) proc1.start() print("Is proc1 alive ",proc1.is_alive()) proc1.join() print("Is proc1 alive ",proc1.is_alive()) print("Finished")
Output
Is proc1 alive True process1 31761 Is proc1 alive False Finished
No comments:
Post a Comment