@@ -140,7 +140,7 @@ async def handle_frontend_bundle(self, request: web.Request):
140140 with open (path .join (self .plugin_path , plugin .plugin_directory , "dist/index.js" ), "r" , encoding = "utf-8" ) as bundle :
141141 return web .Response (text = bundle .read (), content_type = "application/javascript" )
142142
143- def import_plugin (self , file : str , plugin_directory : str , refresh : bool | None = False , batch : bool | None = False ):
143+ async def import_plugin (self , file : str , plugin_directory : str , refresh : bool | None = False , batch : bool | None = False ):
144144 try :
145145 async def plugin_emitted_event (event : str , args : Any ):
146146 self .logger .debug (f"PLUGIN EMITTED EVENT: { event } with args { args } " )
@@ -152,7 +152,7 @@ async def plugin_emitted_event(event: str, args: Any):
152152 self .logger .info (f"Plugin { plugin .name } is already loaded and has requested to not be re-loaded" )
153153 return
154154 else :
155- self .plugins [plugin .name ].stop ()
155+ await self .plugins [plugin .name ].stop ()
156156 self .plugins .pop (plugin .name , None )
157157 if plugin .passive :
158158 self .logger .info (f"Plugin { plugin .name } is passive" )
@@ -168,18 +168,18 @@ async def plugin_emitted_event(event: str, args: Any):
168168 async def dispatch_plugin (self , name : str , version : str | None , load_type : int = PluginLoadType .ESMODULE_V1 .value ):
169169 await self .ws .emit ("loader/import_plugin" , name , version , load_type )
170170
171- def import_plugins (self ):
171+ async def import_plugins (self ):
172172 self .logger .info (f"import plugins from { self .plugin_path } " )
173173
174174 directories = [i for i in listdir (self .plugin_path ) if path .isdir (path .join (self .plugin_path , i )) and path .isfile (path .join (self .plugin_path , i , "plugin.json" ))]
175175 for directory in directories :
176176 self .logger .info (f"found plugin: { directory } " )
177- self .import_plugin (path .join (self .plugin_path , directory , "main.py" ), directory , False , True )
177+ await self .import_plugin (path .join (self .plugin_path , directory , "main.py" ), directory , False , True )
178178
179179 async def handle_reloads (self ):
180180 while True :
181181 args = await self .reload_queue .get ()
182- self .import_plugin (* args ) # pyright: ignore [reportArgumentType]
182+ await self .import_plugin (* args ) # pyright: ignore [reportArgumentType]
183183
184184 async def handle_plugin_method_call_legacy (self , plugin_name : str , method_name : str , kwargs : Dict [Any , Any ]):
185185 res : Dict [Any , Any ] = {}
0 commit comments