From ebfbfb2dfc416e8c52ceeb03ea0545e3a1f9ea5c Mon Sep 17 00:00:00 2001 From: TheWCKD Date: Mon, 24 Jul 2023 18:38:22 +0300 Subject: [PATCH] added posibility to handle exception on RequestTimeout --- telebot/async_telebot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 981ad25..b3f189e 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -415,8 +415,16 @@ class AsyncTeleBot: except asyncio.CancelledError: return except asyncio_helper.RequestTimeout as e: - logger.error(str(e)) - if non_stop: + handled = False + if self.exception_handler: + self.exception_handler.handle(e) + handled = True + + if not handled: + logger.error('Unhandled exception (full traceback for debug level): %s', str(e)) + logger.debug(traceback.format_exc()) + + if non_stop or handled: await asyncio.sleep(2) continue else: