python-dependency-injector/examples/miniapps/asyncio-daemon/monitoringdaemon/http.py

12 lines
371 B
Python
Raw Permalink Normal View History

"""Http client module."""
from aiohttp import ClientSession, ClientTimeout, ClientResponse
class HttpClient:
async def request(self, method: str, url: str, timeout: int) -> ClientResponse:
async with ClientSession(timeout=ClientTimeout(timeout)) as session:
async with session.request(method, url) as response:
return response