mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 12:59:46 +00:00
Start background thread only if it was None
This commit is contained in:
@@ -1041,11 +1041,12 @@ class TelegramClient(TelegramBareClient):
|
|||||||
|
|
||||||
def _set_connected_and_authorized(self):
|
def _set_connected_and_authorized(self):
|
||||||
self._authorized = True
|
self._authorized = True
|
||||||
self._recv_thread = Thread(
|
if self._recv_thread is None:
|
||||||
name='ReadThread', daemon=True,
|
self._recv_thread = Thread(
|
||||||
target=self._recv_thread_impl
|
name='ReadThread', daemon=True,
|
||||||
)
|
target=self._recv_thread_impl
|
||||||
self._recv_thread.start()
|
)
|
||||||
|
self._recv_thread.start()
|
||||||
|
|
||||||
# By using this approach, another thread will be
|
# By using this approach, another thread will be
|
||||||
# created and started upon connection to constantly read
|
# created and started upon connection to constantly read
|
||||||
@@ -1075,7 +1076,8 @@ class TelegramClient(TelegramBareClient):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Unknown exception, pass it to the main thread
|
# Unknown exception, pass it to the main thread
|
||||||
self.updates.set_error(e)
|
self.updates.set_error(e)
|
||||||
self._recv_thread = None
|
break
|
||||||
return
|
|
||||||
|
self._recv_thread = None
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
Reference in New Issue
Block a user