Assert properties exist on disconnect

This commit is contained in:
Lonami Exo 2018-06-26 12:03:31 +02:00
parent 1da0018a5d
commit 9971145721

View File

@ -291,10 +291,13 @@ class TelegramBaseClient(abc.ABC):
"""
Disconnects from Telegram.
"""
# All properties may be ``None`` if `__init__` fails, and this
# method will be called from `__del__` which would crash then.
if self._sender:
await self._sender.disconnect()
if self._updates_handle:
await self._updates_handle
if self.session:
self.session.close()
def __del__(self):