This commit is contained in:
2024-07-06 05:30:26 +03:00
parent 7faf63809d
commit 2fac36f005

View File

@@ -2,10 +2,12 @@ from abc import ABC, abstractmethod
from typing import Literal, Union from typing import Literal, Union
import aiohttp import aiohttp
from aiohttp import ClientResponse from aiohttp import ClientResponse, TCPConnector
from database import Marketplace from database import Marketplace
shared_connector = TCPConnector(limit=50000)
class BaseMarketplaceApi(ABC): class BaseMarketplaceApi(ABC):
@abstractmethod @abstractmethod
@@ -28,7 +30,7 @@ class BaseMarketplaceApi(ABC):
async def _method(self, http_method: Literal['POST', 'GET', 'PATCH', 'PUT', 'DELETE'], async def _method(self, http_method: Literal['POST', 'GET', 'PATCH', 'PUT', 'DELETE'],
method: str, method: str,
data: dict) -> ClientResponse: data: dict) -> ClientResponse:
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession(connector=shared_connector) as session:
return await session.request(http_method, return await session.request(http_method,
f'{self.api_url}{method}', f'{self.api_url}{method}',
json=data, json=data,