@@ -140,7 +140,7 @@ async def handle_frontend_bundle(self, request: web.Request):
140
140
with open (path .join (self .plugin_path , plugin .plugin_directory , "dist/index.js" ), "r" , encoding = "utf-8" ) as bundle :
141
141
return web .Response (text = bundle .read (), content_type = "application/javascript" )
142
142
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 ):
144
144
try :
145
145
async def plugin_emitted_event (event : str , args : Any ):
146
146
self .logger .debug (f"PLUGIN EMITTED EVENT: { event } with args { args } " )
@@ -152,7 +152,7 @@ async def plugin_emitted_event(event: str, args: Any):
152
152
self .logger .info (f"Plugin { plugin .name } is already loaded and has requested to not be re-loaded" )
153
153
return
154
154
else :
155
- self .plugins [plugin .name ].stop ()
155
+ await self .plugins [plugin .name ].stop ()
156
156
self .plugins .pop (plugin .name , None )
157
157
if plugin .passive :
158
158
self .logger .info (f"Plugin { plugin .name } is passive" )
@@ -168,18 +168,18 @@ async def plugin_emitted_event(event: str, args: Any):
168
168
async def dispatch_plugin (self , name : str , version : str | None , load_type : int = PluginLoadType .ESMODULE_V1 .value ):
169
169
await self .ws .emit ("loader/import_plugin" , name , version , load_type )
170
170
171
- def import_plugins (self ):
171
+ async def import_plugins (self ):
172
172
self .logger .info (f"import plugins from { self .plugin_path } " )
173
173
174
174
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" ))]
175
175
for directory in directories :
176
176
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 )
178
178
179
179
async def handle_reloads (self ):
180
180
while True :
181
181
args = await self .reload_queue .get ()
182
- self .import_plugin (* args ) # pyright: ignore [reportArgumentType]
182
+ await self .import_plugin (* args ) # pyright: ignore [reportArgumentType]
183
183
184
184
async def handle_plugin_method_call_legacy (self , plugin_name : str , method_name : str , kwargs : Dict [Any , Any ]):
185
185
res : Dict [Any , Any ] = {}
0 commit comments