Close arkhamdb session in a more clean way
This commit is contained in:
parent
344c65398c
commit
81a083618d
@ -25,6 +25,10 @@ class ArkhamDBUpdater(commands.Bot):
|
|||||||
self.arkhamdb_client = ArkhamDBClient()
|
self.arkhamdb_client = ArkhamDBClient()
|
||||||
self.setup_commands()
|
self.setup_commands()
|
||||||
|
|
||||||
|
async def close(self) -> None:
|
||||||
|
await self.arkhamdb_client.close()
|
||||||
|
await super().close()
|
||||||
|
|
||||||
def setup_commands(self):
|
def setup_commands(self):
|
||||||
@self.command(name='monitor')
|
@self.command(name='monitor')
|
||||||
async def monitor(ctx: commands.Context):
|
async def monitor(ctx: commands.Context):
|
||||||
|
@ -17,10 +17,6 @@ class ArkhamDBClient:
|
|||||||
self._session = aiohttp.ClientSession()
|
self._session = aiohttp.ClientSession()
|
||||||
self.origin = arkhamdb_origin
|
self.origin = arkhamdb_origin
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
loop.run_until_complete(self.close())
|
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
await self._session.close()
|
await self._session.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user