1
0
Fork 0
mirror of https://github.com/SlavikMIPT/tgcloud.git synced 2025-02-12 19:22:29 +00:00

set_upload_threads_count

This commit is contained in:
slavikmipt 2018-07-04 21:04:59 +03:00
parent 6b25d06bd8
commit 4b93bfb74c
2 changed files with 8 additions and 2 deletions

View file

@ -1,2 +1,6 @@
# tgcloud # tgcloud
Opensourse Telegram based cloud storage Opensourse Telegram based cloud storage
using:
from telegram_client_x import TelegramClientX
client = TelegramClientX(entity, api_id, api_hash, update_workers=None, spawn_read_thread=True)
client.set_upload_threads_count(24)

View file

@ -60,6 +60,7 @@ class TelegramClientX(TelegramClient):
self._phone_code_hash = {} self._phone_code_hash = {}
self._phone = None self._phone = None
self._session_name = session self._session_name = session
self._upload_threads_count = 8
# Sometimes we need to know who we are, cache the self peer # Sometimes we need to know who we are, cache the self peer
self._self_input_peer = None self._self_input_peer = None
@ -90,7 +91,8 @@ class TelegramClientX(TelegramClient):
self.client.disconnect() self.client.disconnect()
print('Thread {0} stopped result {1}'.format(self.name, self.result)) print('Thread {0} stopped result {1}'.format(self.name, self.result))
return return
def set_upload_threads_count(self,count: int):
self._upload_threads_count = int(count)
def upload_file(self, def upload_file(self,
file, file,
part_size_kb=None, part_size_kb=None,
@ -196,7 +198,7 @@ class TelegramClientX(TelegramClient):
file_size, part_count, part_size) file_size, part_count, part_size)
with open(file, 'rb') if isinstance(file, str) else BytesIO(file) as stream: with open(file, 'rb') if isinstance(file, str) else BytesIO(file) as stream:
threads_count = 24 threads_count = self._upload_threads_count
if part_count < threads_count: if part_count < threads_count:
threads_count = part_count threads_count = part_count
upload_thread = [] upload_thread = []