Функция
_do_async_request
будет асинхронной или все упрется в ожидании ответа http?
def _do_request(self, url: str, params: dict=None) -> Answer:
request_params = {"login": self._login, "passwd": self._password}
if params is not None:
request_params["input_format"] = "json"
request_params["input_data"] = json.dumps(params, separators=(',',':'))
if self._asynchronous:
loop = asyncio.new_event_loop()
result = loop.run_until_complete(self._do_async_request(url, request_params)) # вот тут
return result
response = requests.get(url, request_params)
return Answer(response.text)
async def _do_async_request(self, url, params):
async with aiohttp.ClientSession() as session:
async with session.post(url, data=params) as response:
return Answer(await response.text())