mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-17 21:22:40 +00:00
Tune upload pool size and workers count
Use 1 worker only in case of small files
This commit is contained in:
parent
4b73358922
commit
99af3a4180
@ -1447,11 +1447,13 @@ class Client(Methods, BaseClient):
|
|||||||
|
|
||||||
file_total_parts = int(math.ceil(file_size / part_size))
|
file_total_parts = int(math.ceil(file_size / part_size))
|
||||||
is_big = file_size > 10 * 1024 * 1024
|
is_big = file_size > 10 * 1024 * 1024
|
||||||
|
pool_size = 3 if is_big else 1
|
||||||
|
workers_count = 4 if is_big else 1
|
||||||
is_missing_part = file_id is not None
|
is_missing_part = file_id is not None
|
||||||
file_id = file_id or self.rnd_id()
|
file_id = file_id or self.rnd_id()
|
||||||
md5_sum = md5() if not is_big and not is_missing_part else None
|
md5_sum = md5() if not is_big and not is_missing_part else None
|
||||||
pool = [Session(self, self.dc_id, self.auth_key, is_media=True) for _ in range(3)]
|
pool = [Session(self, self.dc_id, self.auth_key, is_media=True) for _ in range(pool_size)]
|
||||||
workers = [asyncio.ensure_future(worker(session)) for session in pool for _ in range(4)]
|
workers = [asyncio.ensure_future(worker(session)) for session in pool for _ in range(workers_count)]
|
||||||
queue = asyncio.Queue(16)
|
queue = asyncio.Queue(16)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user