Unclosed aiohttp Sessions #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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