Base Downloader API¶
The Downloader base class defines the general downloader API. It has a number of simple methods and behaviors that are common across any derived classes. This provides the pluggable aspect of the Nectar library.
A downloader constructor takes two parameters, one required and one optional:
As the downloader downloads files, it fires off events by calling methods on the provided event listener.
If no event listener is passed to a downloader’s constructor, a no-op event listener is automatically used.
Event listener’s methods are described here.
def download(self, request_list):
request_list parameter doesn’t necessarily need to be a list, but it
does need to be an iterator of request objects.
Downloaders support the canceling of the a call to
download via the
cancel method. Since downloading is synchronous and does not return until
all the download requests have been either successfully downloaded or have
failed in their attempt, the
cancel method must be called by another thread.