you can execute OS system call.
here i execute ps -ef and grep the required process name (or you can grep by
pid on that particular column using awk)
import os
os.system("ps -ef | grep -v grep | grep <proc_name>")
in my system it gives result 0 if the process is running
>>> a = os.system("ps -ef | grep -v grep | grep python")
root 8749 5331 0 Jul19 pts/1 00:00:00 python
>>> a
0
else gives non 0 :
>>> a = os.system("ps -ef | grep -v grep | grep python123")
>>> a
256
you can check this inside while True:
I am sure there should be a far better solution that this in python.
-Venky