diff --git a/telebot/apihelper.py b/telebot/apihelper.py index a687066f1..33545d4d2 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -53,7 +53,7 @@ def _get_multipart_header_formatter(urllib3_fields): RETRY_ON_ERROR = False RETRY_TIMEOUT = 2 -MAX_RETRIES = 15 +MAX_RETRIES = 3 RETRY_ENGINE = 1 CUSTOM_SERIALIZER = None diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index c54b8ec13..a90935864 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -25,6 +25,8 @@ FILE_URL = None REQUEST_TIMEOUT = 300 +RETRY_ON_ERROR = False +RETRY_TIMEOUT = 2 MAX_RETRIES = 3 REQUEST_LIMIT = 50 @@ -90,28 +92,28 @@ async def _process_request(token, url, method='get', params=None, files=None, ** params = _prepare_data(params, files) timeout = aiohttp.ClientTimeout(total=request_timeout) - got_result = False - current_try=0 + max_attempts = max(1, MAX_RETRIES if RETRY_ON_ERROR else 1) + last_error = None session = await session_manager.get_session() - while not got_result and current_try