Add _unload to decky template

This commit is contained in:
NGnius (Graham) 2023-04-04 19:30:40 -04:00
parent 4f095475f6
commit 909bab400b

View file

@ -11,6 +11,18 @@ class Plugin:
# Asyncio-compatible long-running code, executed in a task when the plugin is loaded
async def _main(self):
# startup
self.backend_proc = subprocess.Popen([PARENT_DIR + "/bin/backend"])
self.backend_proc = subprocess.Popen(
[PARENT_DIR + "/bin/backend"],
env = dict(os.environ))
while True:
await asyncio.sleep(1)
async def _unload(self):
# shutdown
if self.backend_proc is not None:
self.backend_proc.terminate()
try:
self.backend_proc.wait(timeout=5) # 5 seconds timeout
except subprocess.TimeoutExpired:
self.backend_proc.kill()
self.backend_proc = None