mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 12:57:52 +00:00
Wait for threads to stop when closing the session
This commit is contained in:
parent
0231ce58d5
commit
5128f6310b
@ -124,11 +124,6 @@ class Session:
|
||||
self.current_salt = FutureSalt(0, 0, self._send(functions.Ping(0)).new_server_salt)
|
||||
self.current_salt = self._send(functions.GetFutureSalts(1)).salts[0]
|
||||
|
||||
if self.next_salt_thread is not None:
|
||||
self.next_salt_thread.join()
|
||||
|
||||
self.next_salt_thread_event.clear()
|
||||
|
||||
self.next_salt_thread = Thread(target=self.next_salt, name="NextSaltThread")
|
||||
self.next_salt_thread.start()
|
||||
|
||||
@ -147,11 +142,6 @@ class Session:
|
||||
)
|
||||
).text
|
||||
|
||||
if self.ping_thread is not None:
|
||||
self.ping_thread.join()
|
||||
|
||||
self.ping_thread_event.clear()
|
||||
|
||||
self.ping_thread = Thread(target=self.ping, name="PingThread")
|
||||
self.ping_thread.start()
|
||||
|
||||
@ -170,8 +160,16 @@ class Session:
|
||||
|
||||
def stop(self):
|
||||
self.is_connected.clear()
|
||||
|
||||
self.ping_thread_event.set()
|
||||
self.next_salt_thread_event.set()
|
||||
|
||||
self.ping_thread.join()
|
||||
self.next_salt_thread.join()
|
||||
|
||||
self.ping_thread_event.clear()
|
||||
self.next_salt_thread_event.clear()
|
||||
|
||||
self.connection.close()
|
||||
|
||||
for i in range(self.WORKERS):
|
||||
|
Loading…
x
Reference in New Issue
Block a user