fix: enhance setup method with retry logic and return status
This commit is contained in:
@@ -49,7 +49,7 @@ class SetupController:
|
||||
def reset_cache_dir(self, cache_dir: str):
|
||||
self.cache_dir = cache_dir
|
||||
|
||||
def setup(self, config: List[Dict[str, Any]]):
|
||||
def setup(self, config: List[Dict[str, Any]])-> bool:
|
||||
"""
|
||||
Args:
|
||||
config (List[Dict[str, Any]]): list of dict like {str: Any}. each
|
||||
@@ -64,13 +64,18 @@ class SetupController:
|
||||
# make sure connection can be established
|
||||
logger.info(f"try to connect {self.http_server}")
|
||||
retry = 0
|
||||
while retry < 30:
|
||||
while retry < 50:
|
||||
try:
|
||||
_ = requests.get(self.http_server + "/terminal")
|
||||
break
|
||||
except:
|
||||
time.sleep(5)
|
||||
retry += 1
|
||||
logger.info(f"retry: {retry}/50")
|
||||
|
||||
if retry == 50:
|
||||
return False
|
||||
|
||||
|
||||
for cfg in config:
|
||||
config_type: str = cfg["type"]
|
||||
@@ -84,6 +89,8 @@ class SetupController:
|
||||
getattr(self, setup_function)(**parameters)
|
||||
|
||||
logger.info("SETUP: %s(%s)", setup_function, str(parameters))
|
||||
|
||||
return True
|
||||
|
||||
def _download_setup(self, files: List[Dict[str, str]]):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user