Python noob here , I apologize in advance if this is a stupid question.
So , I wrote this code
import subprocess
import os, signal
import time
timeout = time.time() + 60*5
count = 0
while True:
print("running")
if time.time() > timeout:
break
speedtest = subprocess.Popen("C:\Program Files\Speedtest\Speedtest.exe")
time.sleep(30.0)
speedtest.terminate()
I`m trying to open speedtest.exe, keep it open for 30 seconds and close it. I want to keep repeating this for 5 minutes.
But when the process closes for the first time and tries to reopen , I get an error saying another instance is already running.
How can I fix this ?
.terminate()