added the one hour limit to compilation as well

This commit is contained in:
Karma Riuk
2025-03-07 08:59:50 +01:00
parent 9fa7dd53af
commit 3a5cd998fd

View File

@ -60,15 +60,29 @@ class BuildHandler(ABC):
return False return False
def compile_repo(self) -> bool: def compile_repo(self) -> bool:
exec_result = self.container.exec_run(self.compile_cmd()) def timeout_handler(signum, frame):
output = clean_output(exec_result.output) raise TimeoutError("Tests exceeded time limit")
if exec_result.exit_code != 0:
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(3600) # Set timeout to 1 hour (3600 seconds)
try:
exec_result = self.container.exec_run(self.compile_cmd())
output = clean_output(exec_result.output)
if exec_result.exit_code != 0:
self.updates["compiled_successfully"] = False
self.updates["error_msg"] = output
return False
self.updates["compiled_successfully"] = True
return True
except TimeoutError:
self.updates["compiled_successfully"] = False self.updates["compiled_successfully"] = False
self.updates["error_msg"] = output self.updates["error_msg"] = "Compile process killed due to exceeding the 1-hour time limit"
return False return False
self.updates["compiled_successfully"] = True finally:
return True signal.alarm(0) # Cancel the alarm
def test_repo(self) -> bool: def test_repo(self) -> bool:
def timeout_handler(signum, frame): def timeout_handler(signum, frame):