Set users to offline before exiting Mirage

This commit is contained in:
vslg
2020-07-16 22:19:20 -03:00
committed by miruka
parent 189b325a2b
commit b69cbf9d14
2 changed files with 26 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ class.
import asyncio
import logging as log
import os
import pyotherside
import signal
import traceback
from concurrent.futures import Future
@@ -143,6 +144,19 @@ class QMLBridge:
remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace()
def exit_mirage(self) -> None:
"""Used to end some tasks before closing"""
try:
# Set accounts presence to offline
asyncio.run_coroutine_threadsafe(
self.backend.logoff_all(),
self._loop,
).result()
except Exception as e:
print(e)
# The AppImage AppRun script overwrites some environment path variables to
# correctly work, and sets RESTORE_<name> equivalents with the original values.
# If the app is launched from an AppImage, now restore the original values
@@ -162,3 +176,5 @@ except ValueError:
pass
BRIDGE = QMLBridge()
pyotherside.atexit(BRIDGE.exit_mirage)