Spaces:
Sleeping
Sleeping
Slightly improved error logging
Browse files
restrictedpython_code_eval.py
CHANGED
@@ -245,13 +245,11 @@ def _check_correctness(check_program, timeout, task_id, completion_id,
|
|
245 |
additional_globals, additional_locals, allowed_imports
|
246 |
)
|
247 |
p = multiprocessing.Process(target=_unsafe_execute, args=args)
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
except EOFError as e:
|
254 |
-
result.append(f"EOFError: {e}")
|
255 |
|
256 |
if not result:
|
257 |
result.append("timed out")
|
@@ -398,10 +396,12 @@ def _unsafe_execute(check_program, result, timeout,
|
|
398 |
byte_code = compile_restricted(check_program, filename="<model output>", mode="exec")
|
399 |
exec(byte_code, exec_globals, additional_locals)
|
400 |
result.append("passed")
|
|
|
|
|
401 |
except TimeoutException:
|
402 |
result.append("timed out")
|
403 |
except BaseException as e:
|
404 |
-
result.append(f"failed: {e}")
|
405 |
|
406 |
# Needed for cleaning up.
|
407 |
shutil.rmtree = rmtree
|
|
|
245 |
additional_globals, additional_locals, allowed_imports
|
246 |
)
|
247 |
p = multiprocessing.Process(target=_unsafe_execute, args=args)
|
248 |
+
p.start()
|
249 |
+
p.join(timeout=timeout + 1)
|
250 |
+
if p.is_alive():
|
251 |
+
p.kill()
|
252 |
+
|
|
|
|
|
253 |
|
254 |
if not result:
|
255 |
result.append("timed out")
|
|
|
396 |
byte_code = compile_restricted(check_program, filename="<model output>", mode="exec")
|
397 |
exec(byte_code, exec_globals, additional_locals)
|
398 |
result.append("passed")
|
399 |
+
except EOFError:
|
400 |
+
result.append("EOF error")
|
401 |
except TimeoutException:
|
402 |
result.append("timed out")
|
403 |
except BaseException as e:
|
404 |
+
result.append(f"failed ({type(e)}): {str(e)}")
|
405 |
|
406 |
# Needed for cleaning up.
|
407 |
shutil.rmtree = rmtree
|