Don't disconnect on del if already disconnected/loop closed

This commit is contained in:
Lonami Exo 2018-06-27 13:57:17 +02:00
parent 72835dfb44
commit a46a45d060

View File

@ -309,6 +309,9 @@ class TelegramBaseClient(abc.ABC):
await self._updates_handle await self._updates_handle
def __del__(self): def __del__(self):
if not self.is_connected() or self.loop.is_closed():
return
# Python 3.5.2's ``asyncio`` mod seems to have a bug where it's not # Python 3.5.2's ``asyncio`` mod seems to have a bug where it's not
# able to close the pending tasks properly, and letting the script # able to close the pending tasks properly, and letting the script
# complete without calling disconnect causes the script to trigger # complete without calling disconnect causes the script to trigger