Skip to content

Commit

Permalink
Merge pull request #1638 from coder2020official/master
Browse files Browse the repository at this point in the history
Fixes #1637, #1636
  • Loading branch information
Badiboy authored Jul 18, 2022
2 parents 54ad158 + 49d3b46 commit e553f3a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio # for future uses
import ssl
import aiohttp
import certifi
from telebot import types

try:
Expand All @@ -26,18 +28,22 @@

class SessionManager:
def __init__(self) -> None:
self.session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(
limit=REQUEST_LIMIT
))
self.session = None
self.ssl_context = ssl.create_default_context(cafile=certifi.where())


async def create_session(self):
self.session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(
limit=REQUEST_LIMIT
limit=REQUEST_LIMIT,
ssl_context=self.ssl_context
))
return self.session

async def get_session(self):
if self.session is None:
self.session = await self.create_session()
return self.session

if self.session.closed:
self.session = await self.create_session()

Expand Down

0 comments on commit e553f3a

Please sign in to comment.