terryyz commited on
Commit
1a7969b
·
verified ·
1 Parent(s): 5ba27b9

add timer back

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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
- # 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"
 
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"