Method Name
is_alive
Method Signature
is_alive()
Returns
bool
True – If the process is alive
Fale – If the process is not alive
Parameters
Not Applicable
Method Overview
- Returns the process status corresponding to a Process instance (whether the process is alive or not).
Example
import multiprocessing as multiproc
import time
def processFunction(messageQueue):
for i in range(1, 10):
messageQueue.put("Message from Child Process")
time.sleep(1)
if __name__ == "__main__":
multiproc.set_start_method("fork")
messageQueue = multiproc.Queue()
childProcess = multiproc.Process(target=processFunction, args=(messageQueue,))
childProcess.start()
print("The child process is alive:%s"%childProcess.is_alive())
childProcess.join()
print("The child process is alive:%s"%childProcess.is_alive())
print("Parent process exiting")Output
The child process is alive:True
The child process is alive:False
Parent process exiting