Parfive is an asynchronous HTTP and FTP parallel file downloader for Python. It leverages `asyncio` to efficiently download multiple files concurrently, providing features like progress bars, connection throttling, and retry mechanisms. The current version, 2.3.1, offers a robust asynchronous API for managing large-scale file transfers. Releases are made periodically to add features, address issues, and ensure compatibility with newer Python versions, maintaining an active development status.
pip install parfiveVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `parfive.Downloader` to download multiple public files concurrently to a local directory. It shows how to initialize the downloader, add URLs, and await the results. The `asyncio.run()` function is used to execute the asynchronous main function.
Review the official `parfive` documentation for the 2.x API. Ensure all `parfive` operations are `await`ed and run within an `asyncio` event loop. Adapt code to handle `Results` objects.
Ensure your code calls `downloader.download()` with `await` and that the execution context is an `asyncio` event loop (e.g., using `asyncio.run()` for top-level script execution, or within an `await`-able function in an existing event loop).
If fresh downloads are always needed, ensure target paths are unique (e.g., by including a timestamp) or explicitly delete existing files before calling `add_url`. Consider checking `overwrite=True` if that option exists or checking the `checksum`.
Tune `max_conn` and `max_downloads` based on your system's capabilities, network bandwidth, and the policies of the servers you are downloading from. Start with conservative values and increase gradually if performance allows.
If in Jupyter, use `await` directly at the top level (if supported) or `nest_asyncio.apply()`. If within another async function, just `await` the parfive call without `asyncio.run()`.
Ensure you use `await downloader.download()` to properly execute the asynchronous download process and retrieve its results.
Change `parfive.Downloader` to `Downloader` after using `from parfive import Downloader` or ensure you are importing the `Downloader` class correctly.