From d5a1c15db3c62784d195ec90995b79bb0f10d2e9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 2 Oct 2022 13:25:29 +0200 Subject: [PATCH] Prevent multiple stop_async calls --- src/bot/application.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bot/application.py b/src/bot/application.py index 7af5db79..aec07e03 100644 --- a/src/bot/application.py +++ b/src/bot/application.py @@ -34,6 +34,8 @@ class Application(DiscordBotApplicationABC): self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC) self._translate: TranslatePipe = services.get_service(TranslatePipe) + self._is_stopping = False + async def configure(self): self._translation.load_by_settings(self._configuration.get_configuration(TranslationSettings)) @@ -47,6 +49,10 @@ class Application(DiscordBotApplicationABC): self._logger.error(__name__, 'Start failed', e) async def stop_async(self): + if self._is_stopping: + return + + self._is_stopping = True try: self._logger.trace(__name__, f'Try to stop {DiscordBotService.__name__}') await self._bot.close()