Skip to content

Commit

Permalink
Fix TL bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Feb 12, 2025
1 parent fa416f0 commit 41a0c76
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/sinol_make/executors/detailed.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ def _execute(self, cmdline: str, time_limit: int, hard_time_limit: int, memory_l
time_used = time.time() - start_time
mem_used = mem_used // 1024

with open(result_file_path, "w") as result_file:
result_file.write(f"{time_used}\n{mem_used}\n{process.returncode}\n")

if stderr == subprocess.PIPE:
_, proc_stderr = process.communicate()
proc_stderr = proc_stderr.decode('utf-8').split('\n')
else:
proc_stderr = []
process.communicate()

with open(result_file_path, "w") as result_file:
result_file.write(f"{time_used}\n{mem_used}\n{process.returncode}\n")

return timeout, mem_used > memory_limit, 0, proc_stderr

def _parse_result(self, tle, mle, return_code, result_file_path) -> ExecutionResult:
Expand All @@ -79,6 +81,8 @@ def _parse_result(self, tle, mle, return_code, result_file_path) -> ExecutionRes
result.Time = float(lines[0].strip())
result.Memory = float(lines[1].strip())
program_exit_code = int(lines[2].strip())
if program_exit_code == -9 or program_exit_code == 9: # Process was killed, so probably TLE
program_exit_code = 0
else:
result.Status = Status.RE
result.Error = "Unexpected output from execution:\n" + "".join(lines)
Expand Down

0 comments on commit 41a0c76

Please sign in to comment.