mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 21:24:35 +03:00
Restore updates thread on reconnection and fix restarting it
This commit is contained in:
parent
bea1b7f526
commit
5f4e79542f
|
@ -133,7 +133,15 @@ class TelegramClient(TelegramBareClient):
|
||||||
|
|
||||||
*args will be ignored.
|
*args will be ignored.
|
||||||
"""
|
"""
|
||||||
return super().connect()
|
result = super().connect()
|
||||||
|
|
||||||
|
# Checking if there are update_handlers and if true, start running updates thread.
|
||||||
|
# This situation may occur on reconnecting.
|
||||||
|
if result and self._update_handlers:
|
||||||
|
self._set_updates_thread(running=True)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
"""Disconnects from the Telegram server
|
"""Disconnects from the Telegram server
|
||||||
|
@ -914,7 +922,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
name='UpdatesThread', daemon=True,
|
name='UpdatesThread', daemon=True,
|
||||||
target=self._updates_thread_method)
|
target=self._updates_thread_method)
|
||||||
|
|
||||||
self._updates_thread.start()
|
self._updates_thread.start()
|
||||||
else:
|
else:
|
||||||
self._updates_thread_running.clear()
|
self._updates_thread_running.clear()
|
||||||
if self._updates_thread_receiving.is_set():
|
if self._updates_thread_receiving.is_set():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user