mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-15 19:10:57 +03:00
Start background thread only if it was None
This commit is contained in:
parent
d8bf8bb2eb
commit
6d60e83adc
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user