Spaces:
Runtime error
Runtime error
add timer back
Browse files78 unmodified lines798081828384858283848586878889878889909192939495969697989978 unmodified lines process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) # def kill_process(): # if process.poll() is None: # If the process is still running # process.terminate() # yield "Process terminated after 6 minutes timeout.\n" def kill_process(): if process.poll() is None: # If the process is still running process.terminate() yield "Process terminated after 6 minutes timeout.\n"
# # Start a timer to kill the process after 6 minutes # timer = threading.Timer(360, kill_process) # timer.start() Start a timer to kill the process after 6 minutes timer = threading.Timer(360, kill_process) timer.start() for line in process.stdout: yield line process.wait() # timer.cancel() timer.cancel() if process.returncode != 0: yield f"Error: Command exited with status {process.returncode}\n"app.py+8-8