mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 20:59:29 +00:00
Don't spawn unnecessary threads when no_updates=True
This commit is contained in:
parent
2ba921c84d
commit
8681ca2043
@ -216,7 +216,7 @@ class Client(Methods, BaseClient):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Unknown storage engine")
|
raise ValueError("Unknown storage engine")
|
||||||
|
|
||||||
self.dispatcher = Dispatcher(self, workers)
|
self.dispatcher = Dispatcher(self, 0 if no_updates else workers)
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self.start()
|
return self.start()
|
||||||
@ -302,15 +302,16 @@ class Client(Methods, BaseClient):
|
|||||||
|
|
||||||
self.load_plugins()
|
self.load_plugins()
|
||||||
|
|
||||||
for i in range(self.UPDATES_WORKERS):
|
if not self.no_updates:
|
||||||
self.updates_workers_list.append(
|
for i in range(self.UPDATES_WORKERS):
|
||||||
Thread(
|
self.updates_workers_list.append(
|
||||||
target=self.updates_worker,
|
Thread(
|
||||||
name="UpdatesWorker#{}".format(i + 1)
|
target=self.updates_worker,
|
||||||
|
name="UpdatesWorker#{}".format(i + 1)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
self.updates_workers_list[-1].start()
|
self.updates_workers_list[-1].start()
|
||||||
|
|
||||||
for i in range(self.DOWNLOAD_WORKERS):
|
for i in range(self.DOWNLOAD_WORKERS):
|
||||||
self.download_workers_list.append(
|
self.download_workers_list.append(
|
||||||
@ -355,13 +356,14 @@ class Client(Methods, BaseClient):
|
|||||||
|
|
||||||
self.download_workers_list.clear()
|
self.download_workers_list.clear()
|
||||||
|
|
||||||
for _ in range(self.UPDATES_WORKERS):
|
if not self.no_updates:
|
||||||
self.updates_queue.put(None)
|
for _ in range(self.UPDATES_WORKERS):
|
||||||
|
self.updates_queue.put(None)
|
||||||
|
|
||||||
for i in self.updates_workers_list:
|
for i in self.updates_workers_list:
|
||||||
i.join()
|
i.join()
|
||||||
|
|
||||||
self.updates_workers_list.clear()
|
self.updates_workers_list.clear()
|
||||||
|
|
||||||
for i in self.media_sessions.values():
|
for i in self.media_sessions.values():
|
||||||
i.stop()
|
i.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user