Spaces:
Sleeping
Sleeping
Terry Zhuo
commited on
Commit
·
91c93fa
1
Parent(s):
0821709
addtimer
Browse files
app.py
CHANGED
@@ -79,10 +79,21 @@ def run_bigcodebench(command):
|
|
79 |
|
80 |
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
for line in process.stdout:
|
83 |
yield line
|
84 |
|
85 |
-
|
|
|
|
|
86 |
|
87 |
if process.returncode != 0:
|
88 |
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"
|