From 83114cab5be90d1a735b401312676604aaf9e2e9 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Sun, 12 Nov 2023 22:16:17 +0100 Subject: [PATCH] [Telegram] fix stop --- Services/Services_bases/telegram_service/telegram.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Services/Services_bases/telegram_service/telegram.py b/Services/Services_bases/telegram_service/telegram.py index 23740832e..dac01dda7 100644 --- a/Services/Services_bases/telegram_service/telegram.py +++ b/Services/Services_bases/telegram_service/telegram.py @@ -17,6 +17,7 @@ import telegram import telegram.ext import telegram.request +import telegram.error import octobot_commons.logging as bot_logging import octobot_services.constants as services_constants @@ -122,7 +123,12 @@ async def _stop_app(self): async def _stop_bot(self): if self.telegram_app.updater.running: - await self.telegram_app.updater.stop() + # await self.telegram_app.updater.shutdown() + try: + await self.telegram_app.updater.stop() + except telegram.error.TimedOut as err: + # can happen, ignore error + self.logger.debug(f"Ignored {err} when stopping telegram bot") if self.telegram_app.running: await self.telegram_app.stop() if self.telegram_app.post_stop: