Spaces:
Runtime error
Runtime error
Terry Zhuo commited on
Commit ·
91c93fa
1
Parent(s): 0821709
addtimer
Browse files78 unmodified lines7980818283848586878889909192938594959697989978 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"
# 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() process.wait() timer.cancel() if process.returncode != 0: yield f"Error: Command exited with status {process.returncode}\n"app.py+12-1