From 629dd400ebd0dca2002a856476fec5aba30bd42a Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 10 Dec 2017 04:00:46 +0200 Subject: [PATCH] Remove auto retry requests on RetryAfter error. --- aiogram/bot/api.py | 9 +-------- aiogram/bot/base.py | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 9025ee00..1cb86308 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -124,7 +124,7 @@ def _compose_data(params=None, files=None): return data -async def request(session, token, method, data=None, files=None, continue_retry=False, **kwargs) -> bool or dict: +async def request(session, token, method, data=None, files=None, **kwargs) -> bool or dict: """ Make request to API @@ -144,8 +144,6 @@ async def request(session, token, method, data=None, files=None, continue_retry= :type data: :obj:`dict` :param files: files :type files: :obj:`dict` - :param continue_retry: - :type continue_retry: :obj:`dict` :return: result :rtype :obj:`bool` or :obj:`dict` """ @@ -158,11 +156,6 @@ async def request(session, token, method, data=None, files=None, continue_retry= return await _check_result(method, response) except aiohttp.ClientError as e: raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}") - except exceptions.RetryAfter as e: - if continue_retry: - await asyncio.sleep(e.timeout) - return await request(session, token, method, data, files, **kwargs) - raise class Methods(Helper): diff --git a/aiogram/bot/base.py b/aiogram/bot/base.py index 9557a7f4..bbec8b31 100644 --- a/aiogram/bot/base.py +++ b/aiogram/bot/base.py @@ -18,7 +18,6 @@ class BaseBot: loop: Optional[Union[asyncio.BaseEventLoop, asyncio.AbstractEventLoop]] = None, connections_limit: Optional[base.Integer] = 10, proxy: str = None, proxy_auth: Optional[aiohttp.BasicAuth] = None, - continue_retry: Optional[bool] = False, validate_token: Optional[bool] = True): """ Instructions how to get Bot token is found here: https://core.telegram.org/bots#3-how-do-i-create-a-bot @@ -33,8 +32,6 @@ class BaseBot: :type proxy: :obj:`str` :param proxy_auth: Authentication information :type proxy_auth: Optional :obj:`aiohttp.BasicAuth` - :param continue_retry: automatic retry sent request when flood control exceeded - :type continue_retry: :obj:`bool` :param validate_token: Validate token. :type validate_token: :obj:`bool` :raise: when token is invalid throw an :obj:`aiogram.utils.exceptions.ValidationError` @@ -48,9 +45,6 @@ class BaseBot: self.proxy = proxy self.proxy_auth = proxy_auth - # Action on error - self.continue_retry = continue_retry - # Asyncio loop instance if loop is None: loop = asyncio.get_event_loop() @@ -123,8 +117,7 @@ class BaseBot: :raise: :obj:`aiogram.exceptions.TelegramApiError` """ return await api.request(self.session, self.__token, method, data, files, - proxy=self.proxy, proxy_auth=self.proxy_auth, - continue_retry=self.continue_retry) + proxy=self.proxy, proxy_auth=self.proxy_auth) async def download_file(self, file_path: base.String, destination: Optional[base.InputFile] = None,