Fix end of sync with block warning on disconnect

This commit is contained in:
Lonami Exo 2018-07-08 00:04:50 +02:00
parent 54bffb30d8
commit d02cb84abe

View File

@ -1,5 +1,6 @@
import getpass
import hashlib
import inspect
import os
import sys
@ -469,7 +470,12 @@ class AuthMethods(MessageParseMethods, UserMethods):
return await self.start()
def __exit__(self, *args):
self.disconnect()
if self._loop.is_running():
self._loop.create_task(self.disconnect())
elif inspect.iscoroutinefunction(self.disconnect):
self._loop.run_until_complete(self.disconnect())
else:
self.disconnect()
async def __aexit__(self, *args):
await self.disconnect()