Skip to main content
Version: 0.2.0

DeferredRequestStream

ClassPrivateContextSource

stream = DeferredRequestStream(
info: CachedFileInfo,
data: CachedRequest
)
with stream as resp:
resp: ProtocolResponse

Deferred data stream forwarded from the response of a pre-configured request.

By entering the context of this class, a connection to the remote resource will be established. Within this context, a data stream can be read and forwarded.

Arguments

ArgumentTypeRequired
Description
infoCachedFileInfoThe information loaded from the cache.
dataCachedRequestThe request configuration loaded from the cache.

Methods

close

stream.close()

Close all connections if they exist.

note

When exiting from the context, this method will be called automatically.

provide

data: Iterator[bytes] = stream.provide(chunk_size: int = 1024 * 1024)

Create the data provider of this deferred request stream.

Note that this method is designed for being used outside the context. When using this method, it will maintain the context within this stream provider. In other words, the context will be exited when this method get finalized.

warning

The returned iterator data will let the context of stream active. If the iterator is to be dropped, it is recommended that the close() method should be called explictly.

Requires

ArgumentTypeRequired
Description
chunk_sizeintThe chunk size used for forwarding the data.

Returns

ArgumentType
Description
dataIterator[bytes]A stream created by this method.