1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00
This commit is contained in:
_run 2022-07-18 13:47:14 +05:00
parent 54ad1582aa
commit 147278733b

View File

@ -26,9 +26,7 @@ REQUEST_LIMIT = 50
class SessionManager: class SessionManager:
def __init__(self) -> None: def __init__(self) -> None:
self.session = aiohttp.ClientSession(connector=aiohttp.TCPConnector( self.session = None
limit=REQUEST_LIMIT
))
async def create_session(self): async def create_session(self):
@ -38,6 +36,10 @@ class SessionManager:
return self.session return self.session
async def get_session(self): async def get_session(self):
if self.session is None:
self.session = await self.create_session()
return self.session
if self.session.closed: if self.session.closed:
self.session = await self.create_session() self.session = await self.create_session()