diff options
| author | marios <marios8543@gmail.com> | 2022-04-18 15:57:51 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 15:57:51 +0300 |
| commit | fa776f0d0b7b4ca7071f0aa912be84e81caf6b61 (patch) | |
| tree | 535f6f0bb71ab97f17a0ef21eb8f0491ae4ca87d /plugin_loader/plugin.py | |
| parent | 4576fed01baac066a8550018a0922739cc2f8985 (diff) | |
| download | decky-loader-fa776f0d0b7b4ca7071f0aa912be84e81caf6b61.tar.gz decky-loader-fa776f0d0b7b4ca7071f0aa912be84e81caf6b61.zip | |
Callsigns (#37)v1.2.0
* Plugin callsigns, filechangehandler thread bug fix, plugin file perms
- Plugins are now assigned a callsign (a random string), which they use for all internal identification, like resource fetching and method calls. This is to ensure that plugins only access their own resources and methods.
- Made FileChangeHandler send off events to a queue, that is then consumed by the Loader, instead of calling import_plugin on its own, since that caused weird issues with the event loop and the thread watchdog is using.
- Plugins are now owned by root and have read-only permissions. This is handled automatically.
* Improved general look and feel of plugin tab
* Make all plugin entries have the same padding between them
* Make "No plugins installed" text look the same as "No new notifications"
Co-authored-by: WerWolv <werwolv98@gmail.com>
Diffstat (limited to 'plugin_loader/plugin.py')
| -rw-r--r-- | plugin_loader/plugin.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/plugin_loader/plugin.py b/plugin_loader/plugin.py index 033d36fc..0f8880f3 100644 --- a/plugin_loader/plugin.py +++ b/plugin_loader/plugin.py @@ -1,5 +1,5 @@ from importlib.util import spec_from_file_location, module_from_spec -from asyncio import get_event_loop, start_unix_server, open_unix_connection, sleep, Lock +from asyncio import get_event_loop, new_event_loop, set_event_loop, start_unix_server, open_unix_connection, sleep, Lock from os import path, setuid from json import loads, dumps, load from concurrent.futures import ProcessPoolExecutor @@ -25,6 +25,7 @@ class PluginWrapper: self.passive = not path.isfile(self.file) def _init(self): + set_event_loop(new_event_loop()) if self.passive: return setuid(0 if "root" in self.flags else 1000) @@ -46,6 +47,8 @@ class PluginWrapper: data = loads((await reader.readline()).decode("utf-8")) if "stop" in data: get_event_loop().stop() + while get_event_loop().is_running(): + await sleep(0) get_event_loop().close() return d = {"res": None, "success": True} @@ -67,17 +70,16 @@ class PluginWrapper: except: await sleep(0) - def start(self, loop): + def start(self): if self.passive: return self - executor = ProcessPoolExecutor() - loop.run_in_executor( - executor, + get_event_loop().run_in_executor( + ProcessPoolExecutor(), self._init ) return self - def stop(self, loop): + def stop(self): if self.passive: return async def _(self): @@ -85,7 +87,7 @@ class PluginWrapper: self.writer.write((dumps({"stop": True})+"\n").encode("utf-8")) await self.writer.drain() self.writer.close() - loop.create_task(_(self)) + get_event_loop().create_task(_(self)) async def execute_method(self, method_name, kwargs): if self.passive: |
