message: Global timeout for benchmarking in case INTERRUPT() does not work
diff: -import os, sys, subprocess, re, time
  +import os, sys, subprocess, re, time, threading
  last_benchmarked_commit_file = '.last_benchmarked_commit'
  @@ -13,6 +13,9 @@ log_file = 'out.log'
  benchmark_results_folder = 'benchmark_results'
  benchmark_info_folder = os.path.join(benchmark_results_folder, 'info')
  default_start_commit = "9ea358b716b33a4929348dc96acbaa16436d83fa"
  +# 5 minute timeout per benchmark
  +total_timeout = 300
  +
  def get_current_git_version():
  proc = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
  return proc.stdout.readline().rstrip()
  @@ -88,29 +91,53 @@ def make_benchmark_folder(commit):
  os.mkdir(folder_name)
  return folder_name
  +
  +class RunBenchmark(object):
  + def __init__(self, benchmark):
  + self.benchmark = benchmark
  +
  + def run(self, timeout):
  + def run_benchmark_target():
  + self.proc = subprocess.Popen([benchmark_runner, '--out=' + self.out_file, '--log=' + self.log_file, self.benchmark], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  + self.proc.communicate()
  +
  + thread = threading.Thread(target=run_benchmark_target)
  + thread.start()
  +
  + thread.join(timeout)
  + if thread.is_alive():
  + self.proc.terminate()
  + thread.join()
  + return 1
  + return self.proc.returncode
  +
  +
  def run_benchmark(benchmark, folder):
  log("Starting benchmark " + benchmark);
  base_path = os.path.join(folder, benchmark)
  - file_name = base_path + ".csv"
  - log_name = base_path + ".log"
  - stdout_name = base_path + ".stdout.log"
  - stderr_name = base_path + ".stderr.log"
  - proc = subprocess.Popen([benchmark_runner, '--out=' + out_file, '--log=' + log_file, benchmark], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  - proc.wait()
  - if proc.returncode != 0:
  +
  + runner = RunBenchmark(benchmark)
  + runner.file_name = base_path + ".csv"
  + runner.log_name = base_path + ".log"
  + runner.stdout_name = base_path + ".stdout.log"
  + runner.stderr_name = base_path + ".stderr.log"
  +
  + return_code = runner.run(total_timeout)
  +
  + if return_code != 0:
  log("Failed to run benchmark " + benchmark);
  # failed to run benchmark
  - with open(file_name, 'w+') as f:
  + with open(runner.file_name, 'w+') as f:
  f.write("CRASH")
  else:
  log("Succeeded in running benchmark " + benchmark);
  # succeeded, copy results to output directory
  - os.rename(out_file, file_name)
  - os.rename(log_file, log_name)
  - with open(stdout_name, 'w+') as f:
  - f.write(proc.stdout.read())
  - with open(stderr_name, 'w+') as f:
  - f.write(proc.stderr.read())
  + os.rename(runner.out_file, runner.file_name)
  + os.rename(runner.log_file, runner.log_name)
  + with open(runner.stdout_name, 'w+') as f:
  + f.write(runner.proc.stdout.read())
  + with open(runner.stderr_name, 'w+') as f:
  + f.write(runner.proc.stderr.read())
  def write_benchmark_info(benchmark, folder):
  file = os.path.join(folder, benchmark + '.log')
  