Skip to content

Commit

Permalink
Issue #140: kotatogram's upload speed boost big
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmo committed Jun 19, 2023
1 parent 1da6f8a commit dd72cfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ hachoir
scandir; python_version<'3.6'
prompt_toolkit
pysocks
more-itertools
4 changes: 2 additions & 2 deletions telegram_upload/client/telegram_download_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def _download_file(
try:
# The speed of this code can be improved. 10 requests are made in parallel, but it waits for all 10 to
# finish before launching another 10.
for tasks in grouper(self._iter_download_chunk(input_location, part_size, dc_id, msg_data, file_size),
for tasks in grouper(self._iter_download_chunk_tasks(input_location, part_size, dc_id, msg_data, file_size),
PARALLEL_DOWNLOAD_BLOCKS):
tasks = list(filter(bool, tasks))
await asyncio.wait(tasks)
Expand Down Expand Up @@ -124,7 +124,7 @@ async def _download_file(
if isinstance(file, str) or in_memory:
f.close()

def _iter_download_chunk(self, input_location, part_size, dc_id, msg_data, file_size):
def _iter_download_chunk_tasks(self, input_location, part_size, dc_id, msg_data, file_size):
for i in range(0, file_size, part_size):
yield self.loop.create_task(
anext(self._iter_download(input_location, offset=i, request_size=part_size, dc_id=dc_id,
Expand Down

0 comments on commit dd72cfa

Please sign in to comment.