Question

For security reasons I need to check on a reoccurring basis if a child process is still alive. I spawned it like this:

NdeProc = Process(target=NodeRun, args=(NodeQ,))
NdeProc.start()

And I really only want to check in my main process if the "NodeRun" is still going? I haven't found anything in the docu yet and thought I might need to do a timestamp file in which I'd keep updating a timestamp from the child process and the parent process could just check it but I was wondering if there's a better method somone could come up with?

Thanks!

Was it helpful?

Solution

Use is_alive() for this:

if NdeProc.is_alive():
    ...
else:
    ...

From the documentation:

Return whether the process is alive. Roughly, a process object is alive from the moment the start() method returns until the child process terminates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top