Muennighoff jiiiiin commited on
Commit
fee8e8d
1 Parent(s): 715eb84

fix: rust timeout exception (#1)

Browse files

- fix: rust timeout exception (11f8d4a688e4ae6689969fb4e29ae4e6957d0f6f)


Co-authored-by: J Noah <jiiiiin@users.noreply.huggingface.co>

Files changed (1) hide show
  1. execute.py +9 -6
execute.py CHANGED
@@ -241,12 +241,15 @@ def unsafe_execute_rust(check_program, result, timeout, cargo_string):
241
 
242
  compilation_result = subprocess.run(["cargo", "check", "--bin", "test", "--message-format", "json"], timeout=timeout, capture_output=True)
243
  if compilation_result.returncode == 0:
244
- exec_result = subprocess.run(["cargo", "test", "--bin", "test", "--message-format", "json"], timeout=timeout, capture_output=True)
245
- if exec_result.returncode == 0:
246
- result.append("passed")
247
- else:
248
- err = compilation_result.stderr.decode() if compilation_result.stderr else compilation_result.stdout.decode()
249
- result.append("failed: execution error: " + err)
 
 
 
250
  else:
251
  err = compilation_result.stderr.decode() if compilation_result.stderr else compilation_result.stdout.decode()
252
  result.append("failed: compilation error: " + err)
 
241
 
242
  compilation_result = subprocess.run(["cargo", "check", "--bin", "test", "--message-format", "json"], timeout=timeout, capture_output=True)
243
  if compilation_result.returncode == 0:
244
+ try:
245
+ exec_result = subprocess.run(["cargo", "test", "--bin", "test", "--message-format", "json"], timeout=timeout, capture_output=True)
246
+ if exec_result.returncode == 0:
247
+ result.append("passed")
248
+ else:
249
+ err = compilation_result.stderr.decode() if compilation_result.stderr else compilation_result.stdout.decode()
250
+ result.append("failed: execution error: " + err)
251
+ except subprocess.TimeoutExpired as e:
252
+ result.append("timed out")
253
  else:
254
  err = compilation_result.stderr.decode() if compilation_result.stderr else compilation_result.stdout.decode()
255
  result.append("failed: compilation error: " + err)