11import importlib
22import threading
3+ from logging import Logger , getLogger
34
45from rcrs_core .connection .componentLauncher import ComponentLauncher
56
3031class AgentLauncher :
3132 def __init__ (self , config : Config ):
3233 self .config = config
34+ self .logger : Logger = getLogger (__name__ )
3335 self .connectors : list [Connector ] = []
36+ self .thread_list : list [threading .Thread ] = []
3437
3538 def initConnector (self ):
3639 loader_name , loader_class_name = self .config .get_value (
37- ConfigKey .KEY_LOADER_CLASS
38- ).split ("." )
39- self .loader : AbstractLoader = importlib .import_module (
40- loader_name ,
41- ).__getattr__ (
40+ ConfigKey .KEY_LOADER_CLASS ,
41+ "adf_core_python.implement.default_loader.DefaultLoader" ,
42+ ).rsplit ("." , 1 )
43+ loader_module = importlib .import_module (loader_name )
44+ self .loader : AbstractLoader = getattr (
45+ loader_module ,
4246 loader_class_name ,
4347 )(
4448 self .config .get_value (ConfigKey .KEY_TEAM_NAME ),
@@ -54,18 +58,23 @@ def initConnector(self):
5458 def launch (self ):
5559 host : str = self .config .get_value (ConfigKey .KEY_KERNEL_HOST , "localhost" )
5660 port : int = self .config .get_value (ConfigKey .KEY_KERNEL_PORT , 27931 )
61+ self .logger .info (f"Start agent launcher (host: { host } , port: { port } )" )
62+
5763 component_launcher : ComponentLauncher = ComponentLauncher (port , host )
5864
59- thread_list : list [threading .Thread ] = []
6065 for connector in self .connectors :
6166 thread = threading .Thread (
6267 target = connector .connect ,
6368 args = (component_launcher , self .config , self .loader ),
6469 )
6570 thread .start ()
66- thread_list .append (thread )
71+ self . thread_list .append (thread )
6772
68- for thread in thread_list :
73+ for thread in self . thread_list :
6974 thread .join ()
7075
7176 connected_agent_count = 0
77+ for connector in self .connectors :
78+ connected_agent_count += connector .get_connected_agent_count ()
79+
80+ self .logger .info (f"Connected agent count: { connected_agent_count } " )
0 commit comments