From 157d1e67ee800f2010a4b2d160c730b4af9dc3eb Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Sun, 23 Jun 2024 15:15:54 +0200 Subject: [PATCH] adding first version of timeout to the execution for lxc --- codeGrader/backend/execution/Execution.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codeGrader/backend/execution/Execution.py b/codeGrader/backend/execution/Execution.py index 8d841ca..03a69b7 100644 --- a/codeGrader/backend/execution/Execution.py +++ b/codeGrader/backend/execution/Execution.py @@ -103,8 +103,9 @@ def execute(self) -> None: start_time = time.time() - output, returncode = self.lxc.lxc_execute_command( - f"python3 {config.executionFilePath}/{script_filename_hash} < {config.executionFilePath}/{testcase_file_hash}") # TODO make better execution function. Not allowed to be hardcoded + command = f"timeout 30s python3 {config.executionFilePath}/{script_filename_hash} < {config.executionFilePath}/{testcase_file_hash}" + + output, returncode = self.lxc.lxc_execute_command(command) # TODO make better execution function. Not allowed to be hardcoded end_time = time.time()