From 0028feb4c5888ce65fec69a3064275e21b1bcd11 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 10 Sep 2022 20:14:48 +0400 Subject: [PATCH] Update asyncio_helper.py --- telebot/asyncio_helper.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 47095a2..8b20d91 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -21,7 +21,7 @@ session = None FILE_URL = None -REQUEST_TIMEOUT = None +REQUEST_TIMEOUT = 300 MAX_RETRIES = 3 REQUEST_LIMIT = 50 @@ -63,12 +63,11 @@ async def _process_request(token, url, method='get', params=None, files=None, ** # ClientTimeout only. # timeout should be added to params for getUpdates. All other timeout's should be used # for request timeout. - try: - request_timeout = kwargs.pop('request_timeout') - # if exception wasn't raised, then we have request_timeout in kwargs(this is getUpdates method) - # so we will simply apply that request_timeout to ClientTimeout - except KeyError: - # exception was raised, so we know that this method is not getUpdates. + request_timeout = kwargs.pop('request_timeout', False) + # if we got some value, then we have request_timeout in kwargs(this is getUpdates method) + # so we will simply apply that request_timeout to ClientTimeout + # and if we got False, then we don't have request_timeout in kwargs(this is not getUpdates method) + if request_timeout is False: # let's check for timeout in params request_timeout = params.pop('timeout', None) # we will apply default request_timeout if there is no timeout in params