Fix updates thread crashing on logout

This commit is contained in:
Lonami Exo
2017-04-14 15:28:15 +02:00
parent f6c34f8ba2
commit 6b2c0271ae
2 changed files with 18 additions and 10 deletions

View File

@@ -259,18 +259,18 @@ class TelegramClient:
def log_out(self):
"""Logs out and deletes the current session. Returns True if everything went OK"""
# Only the logout request is confirmed via an ack request
# TODO This is only a supposition, there has to be a better way to handle acks
self.sender.ack_requests_confirm = True
# Special flag when logging out (so the ack request confirms it)
self.sender.logging_out = True
try:
self.invoke(LogOutRequest())
self.disconnect()
if not self.session.delete():
return False
self.session = None
except:
# Something happened when logging out, restore the state back
self.sender.ack_requests_confirm = False
self.sender.logging_out = False
return False
@staticmethod