b2sdk.transferer.parallel
¶
-
class
b2sdk.transferer.parallel.
AbstractDownloaderThread
(session, writer, part_to_download, chunk_size)[source]¶ Bases:
threading.Thread
-
__init__
(session, writer, part_to_download, chunk_size)[source]¶ - Parameters
session – raw_api wrapper
writer – where to write data
part_to_download – PartToDownload object
chunk_size – internal buffer size to use for writing and hashing
-
abstract
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
-
class
b2sdk.transferer.parallel.
FirstPartDownloaderThread
(response, hasher, *args, **kwargs)[source]¶ Bases:
b2sdk.transferer.parallel.AbstractDownloaderThread
-
__init__
(response, hasher, *args, **kwargs)[source]¶ - Parameters
response – response of the original GET call
hasher – hasher object to feed to as the stream is written
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
-
class
b2sdk.transferer.parallel.
NonHashingDownloaderThread
(url, *args, **kwargs)[source]¶ Bases:
b2sdk.transferer.parallel.AbstractDownloaderThread
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
-
class
b2sdk.transferer.parallel.
ParallelDownloader
(max_streams, min_part_size, *args, **kwargs)[source]¶ Bases:
b2sdk.transferer.abstract.AbstractDownloader
-
FINISH_HASHING_BUFFER_SIZE
= 1048576¶
-
__init__
(max_streams, min_part_size, *args, **kwargs)[source]¶ - Parameters
max_streams – maximum number of simultaneous streams
min_part_size – minimum amount of data a single stream will retrieve, in bytes
-
download
(file, response, metadata, session)[source]¶ Downloads a file from given url using parallel download sessions and stores it in the given download_destination.
- Parameters
file – an opened file-like object to write to
response – The response of the first request made to the cloud service with download intent
- Returns
-
-
class
b2sdk.transferer.parallel.
PartToDownload
(cloud_range, local_range)[source]¶ Bases:
object
Holds the range of a file to download, and the range of the local file where it should be stored.
-
class
b2sdk.transferer.parallel.
WriterThread
(file)[source]¶ Bases:
threading.Thread
-
__init__
(file)[source]¶ This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-