[Python] Parallel download parts of a file

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I am currently having some difficulties with python socket, the specific problems I encounter are below:

    • Server is a place to store files.
    • Each Client downloads each file sequentially according to the list in the input.txt file.
    • For each file that needs to be downloaded, the client will open 4 parallel connections to the Server to start downloading parts of a file.
    • Can be based on the size of the file and divide by 4 to ask the server to send each chunk for each connection.
    • On screen the client allows displaying a percentage (from 0-xx%) based on the download progress of the parts of the file being downloaded (Note: A client can only open 4 connections parallel to the Server to download 1 file). Then, the client needs to join the downloaded parts of a file into a complete file adjust. (check by checking the total capacity and opening the file successfully)
    • Example the console of client while download (suppose the file below has a capacity of 500MB)

    Downloading file1.txt part 1 .... 45%
    Downloading file1.txt part 2 .... 15%
    Downloading file1.txt part 3 .... 25%
    Downloading file1.txt part 4 .... 85%


    I can download with one file but I'm having difficulty dividing the file into 4 parts and then downloading it and reassembling it intact as required. Hope you can give me a sample code or a keyword or video about this topic so I can learn more. Thank you very much.

    Continue reading...

Compartilhe esta Página