Fixed shutdown procedure async problems #1.1.0.rc2

This commit is contained in:
2023-08-16 18:04:40 +02:00
parent 44f6b36347
commit caeec47b7c
5 changed files with 14 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ from bot_core.abc.client_utils_abc import ClientUtilsABC
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.helper.command_checks import CommandChecks
from bot_core.logging.command_logger import CommandLogger
from bot_core.service.data_integrity_service import DataIntegrityService
from modules.permission.abc.permission_service_abc import PermissionServiceABC
@@ -24,6 +25,7 @@ class RestartCommand(DiscordCommandABC):
client_utils: ClientUtilsABC,
translate: TranslatePipe,
permissions: PermissionServiceABC,
data_integrity: DataIntegrityService,
):
DiscordCommandABC.__init__(self)
@@ -34,6 +36,7 @@ class RestartCommand(DiscordCommandABC):
self._client_utils = client_utils
self._t = translate
self._permissions = permissions
self._data_integrity = data_integrity
self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}")
@@ -48,6 +51,7 @@ class RestartCommand(DiscordCommandABC):
await self._client_utils.presence_game("common.presence.restart")
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.restart_message"))
await asyncio.sleep(self._settings.wait_for_restart)
await self._data_integrity.check_data_integrity(is_for_shutdown=True)
await self._bot.stop_async()
self._logger.trace(__name__, f"Finished restart command")

View File

@@ -11,6 +11,7 @@ from bot_core.abc.client_utils_abc import ClientUtilsABC
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.helper.command_checks import CommandChecks
from bot_core.logging.command_logger import CommandLogger
from bot_core.service.data_integrity_service import DataIntegrityService
from bot_data.model.technician_config import TechnicianConfig
from modules.permission.abc.permission_service_abc import PermissionServiceABC
@@ -26,6 +27,7 @@ class ShutdownCommand(DiscordCommandABC):
translate: TranslatePipe,
permissions: PermissionServiceABC,
settings: TechnicianConfig,
data_integrity: DataIntegrityService,
):
DiscordCommandABC.__init__(self)
@@ -37,6 +39,7 @@ class ShutdownCommand(DiscordCommandABC):
self._t = translate
self._permissions = permissions
self._settings = settings
self._data_integrity = data_integrity
self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}")
@@ -50,6 +53,7 @@ class ShutdownCommand(DiscordCommandABC):
await self._client_utils.presence_game("common.presence.shutdown")
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.technician.shutdown_message"))
await asyncio.sleep(self._settings.wait_for_shutdown)
await self._data_integrity.check_data_integrity(is_for_shutdown=True)
await self._bot.stop_async()
self._logger.trace(__name__, f"Finished shutdown command")