Catch calling .receive() when .sender is None on recv_thread

This commit is contained in:
Lonami Exo 2017-09-17 16:37:08 +02:00
parent 12c12fdfaf
commit 05a8723d36

View File

@ -1004,6 +1004,13 @@ class TelegramClient(TelegramBareClient):
self._last_ping = datetime.now()
self._sender.receive(update_state=self.updates)
except AttributeError:
# 'NoneType' object has no attribute 'receive'.
# The only moment when this can happen is reconnection
# was triggered from another thread and the ._sender
# was set to None, so close this thread and exit by return.
self._recv_thread = None
return
except TimeoutError:
# No problem.
pass