Fix LogOutRequest consuming all retries (#270)

This commit is contained in:
Lonami Exo
2017-09-29 13:58:15 +02:00
parent 61e5c73658
commit 56103845de
2 changed files with 20 additions and 21 deletions

View File

@@ -392,19 +392,12 @@ class TelegramClient(TelegramBareClient):
def log_out(self):
"""Logs out and deletes the current session.
Returns True if everything went okay."""
# Special flag when logging out (so the ack request confirms it)
self._sender.logging_out = True
try:
self(LogOutRequest())
# The server may have already disconnected us, we still
# try to disconnect to make sure.
self.disconnect()
except (RPCError, ConnectionError):
# Something happened when logging out, restore the state back
self._sender.logging_out = False
except RPCError:
return False
self.disconnect()
self.session.delete()
self.session = None
return True