I\'m using the killableprocess package (built on top of subprocess) for running processes Whenever I run the \"killableprocess.Popen(command)\" piece of code in my script I
Alternatively, if your module doesn't work, you can use the «subprocess» module:
import subprocess, os, time
process = subprocess.Popen("somecommand", shell=True)
n = 0
while True:
if not process.poll():
print('The command is running...')
if n >= 10:
pid = process.pid()
os.kill(pid, 9) # 9 = SIGKILL
else:
print('The command is not running..')
n += 1
time.sleep(1)