async with aiohttp.ClientSession() as session: # Lines 131, 563
Issue: Creating new sessions for each request is inefficient. Should reuse a single session.
Then use self.http_session everywhere instead of creating new ones
async with aiohttp.ClientSession() as session: # Lines 131, 563
Issue: Creating new sessions for each request is inefficient. Should reuse a single session.
Fix:
class CustomBot(commands.Bot):
def __init__(self):
# ... existing code ...
self.http_session: aiohttp.ClientSession = None
async def setup_hook(self):
self.http_session = aiohttp.ClientSession()
await self.tree.sync()
async def close(self):
if self.http_session:
await self.http_session.close()
await super().close()
# Then use self.http_session everywhere instead of creating new ones
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
async with aiohttp.ClientSession() as session: # Lines 131, 563
Issue: Creating new sessions for each request is inefficient. Should reuse a single session.
Fix:
class CustomBot(commands.Bot):
def init(self):
# ... existing code ...
self.http_session: aiohttp.ClientSession = None
Then use self.http_session everywhere instead of creating new ones