@@ -96,12 +96,23 @@ def __init__(self, name: str, config_dir: Optional[str] = 'config'):
9696 self .before_update : dict [str , Callable [[], Awaitable [Any ]]] = {}
9797 self .after_update : dict [str , Callable [[], Awaitable [Any ]]] = {}
9898 self .locals = self .read_locals ()
99+ self .db_version = None
100+ self .pool : Optional [ConnectionPool ] = None
101+ self .apool : Optional [AsyncConnectionPool ] = None
102+ self ._master = None
103+ self .listen_address = self .locals .get ('listen_address' , '127.0.0.1' )
104+ if self .listen_address != '127.0.0.1' :
105+ self .log .warning (
106+ 'Please consider changing the listen_address in your nodes.yaml to 127.0.0.1 for security reasons!' )
107+ self .listen_port = self .locals .get ('listen_port' , 10042 )
108+
109+ async def __aenter__ (self ):
99110 if sys .platform == 'win32' :
100111 from os import system
101112 system (f"title DCSServerBot v{ self .bot_version } .{ self .sub_version } - { self .node .name } " )
102113 self .log .info (f'DCSServerBot v{ self .bot_version } .{ self .sub_version } starting up ...' )
103114 self .log .info (f'- Python version { platform .python_version ()} detected.' )
104- self .install_plugins ( )
115+ await asyncio . to_thread ( self .install_plugins )
105116 self .plugins : list [str ] = [x .lower () for x in self .config .get ('plugins' , DEFAULT_PLUGINS )]
106117 for plugin in [x .lower () for x in self .config .get ('opt_plugins' , [])]:
107118 if plugin not in self .plugins :
@@ -110,17 +121,6 @@ def __init__(self, name: str, config_dir: Optional[str] = 'config'):
110121 if 'cloud' in self .plugins :
111122 self .plugins .remove ('cloud' )
112123 self .plugins .append ('cloud' )
113- self .db_version = None
114- self .pool : Optional [ConnectionPool ] = None
115- self .apool : Optional [AsyncConnectionPool ] = None
116- self ._master = None
117- self .listen_address = self .locals .get ('listen_address' , '127.0.0.1' )
118- if self .listen_address != '127.0.0.1' :
119- self .log .warning (
120- 'Please consider changing the listen_address in your nodes.yaml to 127.0.0.1 for security reasons!' )
121- self .listen_port = self .locals .get ('listen_port' , 10042 )
122-
123- async def __aenter__ (self ):
124124 return self
125125
126126 async def __aexit__ (self , type , value , traceback ):
0 commit comments