mirror of
https://github.com/karma-riuk/crab.git
synced 2025-07-05 13:38:12 +02:00
added the one hour limit to compilation as well
This commit is contained in:
26
handlers.py
26
handlers.py
@ -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):
|
||||||
|
Reference in New Issue
Block a user