Fix workers not stopping on .disconnect(), start them on login

This commit is contained in:
Lonami Exo
2017-10-01 19:56:24 +02:00
parent 62ea77cbea
commit d98fd6a424
2 changed files with 8 additions and 5 deletions

View File

@@ -267,6 +267,9 @@ class TelegramBareClient:
self._user_connected = False
self._recv_thread = None
# Stop the workers from the background thread
self.updates.stop_workers()
# This will trigger a "ConnectionResetError", for subsequent calls
# to read or send (from another thread) and usually, the background
# thread would try restarting the connection but since the
@@ -747,6 +750,7 @@ class TelegramBareClient:
def _set_connected_and_authorized(self):
self._authorized = True
self.updates.setup_workers()
if self._spawn_read_thread and self._recv_thread is None:
self._recv_thread = threading.Thread(
name='ReadThread', daemon=True,