mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Join net worker threads before stopping. Fixes #62
This commit is contained in:
parent
33c417942c
commit
de332471df
@ -120,6 +120,8 @@ class Session:
|
|||||||
self.next_salt_thread = None
|
self.next_salt_thread = None
|
||||||
self.next_salt_thread_event = Event()
|
self.next_salt_thread_event = Event()
|
||||||
|
|
||||||
|
self.net_worker_list = []
|
||||||
|
|
||||||
self.is_connected = Event()
|
self.is_connected = Event()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
@ -128,7 +130,14 @@ class Session:
|
|||||||
self.connection.connect()
|
self.connection.connect()
|
||||||
|
|
||||||
for i in range(self.NET_WORKERS):
|
for i in range(self.NET_WORKERS):
|
||||||
Thread(target=self.net_worker, name="NetWorker#{}".format(i + 1)).start()
|
self.net_worker_list.append(
|
||||||
|
Thread(
|
||||||
|
target=self.net_worker,
|
||||||
|
name="NetWorker#{}".format(i + 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.net_worker_list[-1].start()
|
||||||
|
|
||||||
Thread(target=self.recv, name="RecvThread").start()
|
Thread(target=self.recv, name="RecvThread").start()
|
||||||
|
|
||||||
@ -190,6 +199,11 @@ class Session:
|
|||||||
for i in range(self.NET_WORKERS):
|
for i in range(self.NET_WORKERS):
|
||||||
self.recv_queue.put(None)
|
self.recv_queue.put(None)
|
||||||
|
|
||||||
|
for i in self.net_worker_list:
|
||||||
|
i.join()
|
||||||
|
|
||||||
|
self.net_worker_list.clear()
|
||||||
|
|
||||||
for i in self.results.values():
|
for i in self.results.values():
|
||||||
i.event.set()
|
i.event.set()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user