Sorry i am new in python subprocess world and I am lost a bit .
We have python script run.py
and from run.py
we are calling another python file named start_process.py
using subprocess
and then in start_process.py
we are starting processes using again subprocess
Basically sudo code goes like
run.py
:
def call_process_script():
cmd = "python start_process.py"
sub_proc = subprocess.Popen(cmd)
while True:
call_process_script()
start_process.py
:
cmd = "java somejava process"
sub_proc = subprocess.Popen(
cmd,stderr=subprocess.STDOUT,stdout=subprocess.PIPE
)
stdoutdata, stderrdata = sub_proc.communicate()
Now I want to restart the java process
after sometime . But I am not able to handle it or control from run.py
or start_process.py
.
I tried to force stop as mentioned and start but no luck Using module 'subprocess' with timeout