mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 22:01:59 +00:00
fixed passive plugin reload bug and close event loop properly
This commit is contained in:
@@ -31,8 +31,6 @@ class FileChangeHandler(FileSystemEventHandler):
|
|||||||
rel_path = path.relpath(src_path, path.commonprefix([self.plugin_path, src_path]))
|
rel_path = path.relpath(src_path, path.commonprefix([self.plugin_path, src_path]))
|
||||||
plugin_dir = path.split(rel_path)[0]
|
plugin_dir = path.split(rel_path)[0]
|
||||||
main_file_path = path.join(self.plugin_path, plugin_dir, "main.py")
|
main_file_path = path.join(self.plugin_path, plugin_dir, "main.py")
|
||||||
if not path.isfile(main_file_path):
|
|
||||||
return
|
|
||||||
self.loader.import_plugin(main_file_path, plugin_dir, refresh=True)
|
self.loader.import_plugin(main_file_path, plugin_dir, refresh=True)
|
||||||
|
|
||||||
def on_modified(self, event):
|
def on_modified(self, event):
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ class PluginWrapper:
|
|||||||
while True:
|
while True:
|
||||||
data = loads((await reader.readline()).decode("utf-8"))
|
data = loads((await reader.readline()).decode("utf-8"))
|
||||||
if "stop" in data:
|
if "stop" in data:
|
||||||
return get_event_loop().stop()
|
get_event_loop().stop()
|
||||||
|
get_event_loop().close()
|
||||||
|
return
|
||||||
d = {"res": None, "success": True}
|
d = {"res": None, "success": True}
|
||||||
try:
|
try:
|
||||||
d["res"] = await getattr(self.Plugin, data["method"])(self.Plugin, **data["args"])
|
d["res"] = await getattr(self.Plugin, data["method"])(self.Plugin, **data["args"])
|
||||||
@@ -82,6 +84,7 @@ class PluginWrapper:
|
|||||||
await self._open_socket_if_not_exists()
|
await self._open_socket_if_not_exists()
|
||||||
self.writer.write((dumps({"stop": True})+"\n").encode("utf-8"))
|
self.writer.write((dumps({"stop": True})+"\n").encode("utf-8"))
|
||||||
await self.writer.drain()
|
await self.writer.drain()
|
||||||
|
self.writer.close()
|
||||||
loop.create_task(_(self))
|
loop.create_task(_(self))
|
||||||
|
|
||||||
async def execute_method(self, method_name, kwargs):
|
async def execute_method(self, method_name, kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user