mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 04:30:22 +03:00
Fixing log_out problems on mac os devices
This commit is contained in:
parent
59f47fe9d9
commit
20a10dfdc3
|
@ -316,33 +316,27 @@ class TelegramClient(TelegramBareClient):
|
||||||
def log_out(self):
|
def log_out(self):
|
||||||
"""Logs out and deletes the current session.
|
"""Logs out and deletes the current session.
|
||||||
Returns True if everything went okay."""
|
Returns True if everything went okay."""
|
||||||
|
|
||||||
# Special flag when logging out (so the ack request confirms it)
|
# Special flag when logging out (so the ack request confirms it)
|
||||||
self._sender.logging_out = True
|
self._sender.logging_out = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self(LogOutRequest())
|
self(LogOutRequest())
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
if not self.session.delete():
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.session = None
|
|
||||||
return True
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
# macos issue: https://github.com/veusz/veusz/issues/54
|
# macos issue: https://github.com/veusz/veusz/issues/54
|
||||||
# socket has been already closed
|
# socket has been already closed (Errno 57)
|
||||||
if e.errno == errno.ENOTCONN:
|
# if any other - fail
|
||||||
if not self.session.delete():
|
if e.errno != errno.ENOTCONN:
|
||||||
return False
|
|
||||||
|
|
||||||
self.session = None
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
raise e
|
raise e
|
||||||
except (RPCError, ConnectionError):
|
except (RPCError, ConnectionError):
|
||||||
# Something happened when logging out, restore the state back
|
# Something happened when logging out, restore the state back
|
||||||
self._sender.logging_out = False
|
self._sender.logging_out = False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
self.session.delete()
|
||||||
|
self.session = None
|
||||||
|
return True
|
||||||
|
|
||||||
def get_me(self):
|
def get_me(self):
|
||||||
"""Gets "me" (the self user) which is currently authenticated,
|
"""Gets "me" (the self user) which is currently authenticated,
|
||||||
or None if the request fails (hence, not authenticated)."""
|
or None if the request fails (hence, not authenticated)."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user