I am trying to make my Python code to start a .bat file, which in turn starts a .exe file. After the process had been launched, I want to wait for a certain amount of time before terminating the .exe process.
However, it seems like any code past the subprocess.call
command that starts .bat file is not being executed.
Here is the code I have so far:
print("About to launch OTB!")
subprocess.call(
".\olympian.bat",
cwd=str(Path(os.path.abspath(__file__)).parent.parent),
shell=True,
)
print("About to sleep")
time.sleep(time_var)
print("Sleep over, will close OTB now!")
subprocess.call("taskkill /F /im olympian.exe")
print("OTB has been closed!")
The program does launch the olympian.bat
process, however it does not display "About to sleep"
message afterward.
Also, the olympian.exe
program supposed to run infinitely long, unless I forcefully close it (with taskkill
command in my case).
Let me know if you need more info, or you know of any way to elegantly make it work. Thanks!