mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1710 from coder2020official/bugfixes
Fixed difference between request_timeout and timeout.
This commit is contained in:
commit
a1c77db236
@ -21,7 +21,7 @@ session = None
|
||||
|
||||
FILE_URL = None
|
||||
|
||||
REQUEST_TIMEOUT = None
|
||||
REQUEST_TIMEOUT = 300
|
||||
MAX_RETRIES = 3
|
||||
|
||||
REQUEST_LIMIT = 50
|
||||
@ -56,10 +56,29 @@ class SessionManager:
|
||||
|
||||
session_manager = SessionManager()
|
||||
|
||||
async def _process_request(token, url, method='get', params=None, files=None, request_timeout=None):
|
||||
async def _process_request(token, url, method='get', params=None, files=None, **kwargs):
|
||||
# Let's resolve all timeout parameters.
|
||||
# getUpdates parameter may contain 2 parameters: request_timeout & timeout.
|
||||
# other methods may contain timeout parameter that should be applied to
|
||||
# ClientTimeout only.
|
||||
# timeout should be added to params for getUpdates. All other timeout's should be used
|
||||
# for request timeout.
|
||||
# here we got request_timeout, so this is getUpdates method.
|
||||
if 'request_timeout' in kwargs:
|
||||
request_timeout = kwargs.pop('request_timeout')
|
||||
|
||||
else:
|
||||
# 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
|
||||
# otherwise, we will use timeout parameter applied for payload.
|
||||
|
||||
request_timeout = REQUEST_TIMEOUT if request_timeout is None else request_timeout
|
||||
|
||||
|
||||
# Preparing data by adding all parameters and files to FormData
|
||||
params = _prepare_data(params, files)
|
||||
if request_timeout is None:
|
||||
request_timeout = REQUEST_TIMEOUT
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=request_timeout)
|
||||
got_result = False
|
||||
current_try=0
|
||||
|
Loading…
Reference in New Issue
Block a user