Spaces:
Sleeping
Sleeping
add timer back
Browse files
app.py
CHANGED
@@ -79,21 +79,21 @@ def run_bigcodebench(command):
|
|
79 |
|
80 |
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
for line in process.stdout:
|
92 |
yield line
|
93 |
|
94 |
process.wait()
|
95 |
|
96 |
-
|
97 |
|
98 |
if process.returncode != 0:
|
99 |
yield f"Error: Command exited with status {process.returncode}\n"
|
|
|
79 |
|
80 |
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
81 |
|
82 |
+
def kill_process():
|
83 |
+
if process.poll() is None: # If the process is still running
|
84 |
+
process.terminate()
|
85 |
+
yield "Process terminated after 6 minutes timeout.\n"
|
86 |
|
87 |
+
Start a timer to kill the process after 6 minutes
|
88 |
+
timer = threading.Timer(360, kill_process)
|
89 |
+
timer.start()
|
90 |
|
91 |
for line in process.stdout:
|
92 |
yield line
|
93 |
|
94 |
process.wait()
|
95 |
|
96 |
+
timer.cancel()
|
97 |
|
98 |
if process.returncode != 0:
|
99 |
yield f"Error: Command exited with status {process.returncode}\n"
|