Remove auto retry requests on RetryAfter error.

This commit is contained in:
Alex Root Junior 2017-12-10 04:00:46 +02:00
parent f529f588da
commit 629dd400eb
2 changed files with 2 additions and 16 deletions

View file

@ -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):

View file

@ -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,