From 2189ee8ff42fda24f4ac900c3f2971baf689be50 Mon Sep 17 00:00:00 2001 From: slavikmipt Date: Thu, 5 Jul 2018 00:53:03 +0300 Subject: [PATCH] refactored --- telegram_client_x.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/telegram_client_x.py b/telegram_client_x.py index fc1ed44..2633ee9 100644 --- a/telegram_client_x.py +++ b/telegram_client_x.py @@ -202,11 +202,9 @@ class TelegramClientX(TelegramClient): file_size, part_count, part_size) with open(file, 'rb') if isinstance(file, str) else BytesIO(file) as stream: - threads_count = 2 + int((self._upload_threads_count - 2) * part_count * 0.000325520) - if threads_count > self._upload_threads_count: - threads_count = self._upload_threads_count - if part_count < threads_count: - threads_count = part_count + threads_count = 2 + int((self._upload_threads_count - 2) * float(file_size) / 1024 * 1024 * 768) + threads_count = min(threads_count, self._upload_threads_count) + threads_count = min(part_count, threads_count) upload_thread = [] q_request = Queue() # spawn threads