A parallel file downloader using asyncio.
Usage
parfive works by creating a downloader object, appending files to it and then running the download. parfive has a synchronous API, but uses asyncio to paralellise downloading the files.
A simple example is:
from parfive import Downloader
dl = Downloader()
dl.enqueue_file("http://data.sunpy.org/sample-data/predicted-sunspot-radio-flux.txt", path="./")
files = dl.download()
Results
parfive.Downloader.download returns a parfive.Results object, which is a list of the filenames that have been downloaded. It also tracks any files which failed to download.
Handling Errors
If files fail to download, the urls and the response from the server are stored in the Results object returned by parfive.Downloader. These can be used to inform users about the errors. (Note, the progress bar will finish in an incomplete state if a download fails, i.e. it will show 4/5 Files Downloaded).
The Results object is a list with an extra attribute errors, this property returns a list of named tuples, where these named tuples contains the .url and the .response, which is a aiohttp.ClientResponse or a aiohttp.ClientError object.
Installation
parfive is available on PyPI, you can install it with pip:
pip install parfive
Requirements
Python 3.5+
aiohttp
tqdm
Licence
MIT Licensed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file parfive-0.1.1.tar.gz.
File metadata
- Download URL: parfive-0.1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb1559682340910d491cc60227e6238730a474917bfdb192ac48340757073298
|
|
| MD5 |
226d3d08cbfaae727164e1b6aa73ff39
|
|
| BLAKE2b-256 |
7a72b60c469f47401fb7d125808ef4d9b29acca3bb6207e0c391e1e28941c3b6
|