From 8335fe029042d88bf6f09d5cc1fa11686ce4d721 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Fri, 16 Feb 2018 16:08:48 +0000 Subject: Automatically close aiohttp session --- bot/cogs/events.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/bot/cogs/events.py b/bot/cogs/events.py index 42f254a0c..325675039 100644 --- a/bot/cogs/events.py +++ b/bot/cogs/events.py @@ -22,16 +22,13 @@ class Events: self.bot = bot async def send_updated_users(self, *users): - session = ClientSession( - headers={"X-API-Key": SITE_API_KEY} - ) - - response = await session.post( - url=SITE_API_USER_URL, - json=list(users) - ) + with ClientSession(headers={"X-API-Key": SITE_API_KEY}) as session: + response = await session.post( + url=SITE_API_USER_URL, + json=list(users) + ) - return await response.json() + return await response.json() async def on_command_error(self, ctx: Context, e: CommandError): command = ctx.command -- cgit v1.2.3