In order to download files, I'm creating a urlopen object (urllib2 class) and reading it in chunks.
I would like to connect to the server several times and download the file in six different sessions. Doing that, the download speed should get faster. Many download managers have this feature.
I thought about specifying the part of file i would like to download in each session, and somehow process all the sessions in the same time. I'm not sure how I can achieve this.
As to running parallel requests you might want to use urllib3 or requests.
I took some time to make a list of similar questions:
Looking for [python] +download +concurrent
gives these interesting ones:
Looking for [python] +http +concurrent
gives these:
Looking for [python] +urllib2 +slow
:
Looking for [python] +download +many
:
map
that works on threadsSounds like you want to use one of the flavors of HTTP Range that are available.
edit Updated link to point to the w3.org stored RFC
As we've been talking already I made such one using PycURL.
The one, and only one, thing I had to do was pycurl_instance.setopt(pycurl_instance.NOSIGNAL, 1)
to prevent crashes.
I did use APScheduler to fire requests in the separate threads. Thanks to your advices of changing busy waiting while True: pass
to while True: time.sleep(3)
in the main thread the code behaves quite nice and usage of Runner module from python-daemon package application is almost ready to be used as a typical UN*X daemon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With