This commit is contained in:
xenia 2021-06-18 03:19:30 -04:00
parent 41bdbc8e37
commit 6fb440c842
1 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,4 @@
import asyncio
from contextlib import suppress
import os
from typing import Optional
@ -67,12 +66,18 @@ class ClientSession:
return api
async def __aexit__(self, *args):
with suppress(Exception):
try:
self.writer.close()
await self.writer.wait_closed()
with suppress(Exception):
except:
pass
try:
self.tasks[0].cancel()
await self.tasks[0]
with suppress(Exception):
except:
pass
try:
self.tasks[1].cancel()
await self.tasks[1]
except:
pass