Skip to content
Advertisement

How to download a file over HTTP with multi-thread (asynchronous download) using Python 2.7

I have a file to download (download path extracted from json. eg: http://testsite/abc.zip).

I need a help to perform, all the 5 threads should download the abc.zip file to the output directory and the download has to be Asynchronous or concurrent.

Currently with the below code it does download the file 5 times but it downloads one by one (Synchronous).

What I want is, the download to be simultaneous.

JavaScript

I have read Requests with multiple connections post and it’s helpful, but doesn’t address the requirement of the question asked.

Advertisement

Answer

I use threading module for download threads:
Also requests, but you can change that to urllib by yourself.

JavaScript
Advertisement