All checks were successful
continuous-integration/drone/push Build is passing
* Delete legacy from bot * Clear old models * Единый http клиент * РАГ полечен
25 lines
577 B
Python
25 lines
577 B
Python
import aiohttp
|
|
from typing import Optional
|
|
|
|
|
|
def create_http_session(timeout: Optional[aiohttp.ClientTimeout] = None) -> aiohttp.ClientSession:
|
|
"""
|
|
Создаем сессию для запросов к бэку
|
|
"""
|
|
if timeout is None:
|
|
timeout = aiohttp.ClientTimeout(total=30, connect=10)
|
|
|
|
connector = aiohttp.TCPConnector(
|
|
limit=100,
|
|
limit_per_host=30
|
|
)
|
|
|
|
return aiohttp.ClientSession(
|
|
connector=connector,
|
|
timeout=timeout,
|
|
headers={
|
|
"Accept": "application/json"
|
|
}
|
|
)
|
|
|