nvflare.fuel.f3.streaming.stream_types module¶
- class ObjectIterator(headers: dict | None = None)[source]¶
Bases:
Iterator
,ABC
An object iterator that returns next object The __next__() method must be defined to return next object.
- class ObjectStreamFuture(stream_id: int, headers: dict | None = None)[source]¶
Bases:
StreamFuture
- class Stream(size: int = 0, headers: dict | None = None)[source]¶
Bases:
ABC
A raw, read-only, seekable binary byte stream
Constructor for stream
- Parameters:
size – The total size of stream. 0 if unknown
headers – Optional headers to be passed to the receiver
- abstract read(chunk_size: int) bytes | bytearray | memoryview | list [source]¶
Read and return up to chunk_size bytes. It can return less but not more than the chunk_size. An empty bytes object is returned if the stream reaches the end.
- Parameters:
chunk_size – Up to (but maybe less) this many bytes will be returned
- Returns:
Binary data. If empty, it means the stream is depleted (EOF)
- exception StreamCancelled[source]¶
Bases:
StreamError
Streaming is cancelled by sender
- class StreamFuture(stream_id: int, headers: dict | None = None)[source]¶
Bases:
object
Future class for all stream calls.
Fashioned after concurrent.futures.Future
- add_done_callback(done_cb: Callable, *args, **kwargs)[source]¶
Attaches a callable that will be called when the future finishes.
- Parameters:
done_cb – A callable that will be called with this future completes
- cancel()[source]¶
Cancel the future if possible.
Returns True if the future was cancelled, False otherwise. A future cannot be cancelled if it is running or has already completed.
- exception(timeout=None)[source]¶
Return the exception raised by the call that the future represents.
- Parameters:
timeout – The number of seconds to wait for the exception if the future isn’t done. If None, then there is no limit on the wait time.
- Returns:
The exception raised by the call that the future represents or None if the call completed without raising.
- Raises:
CancelledError – If the future was cancelled.
TimeoutError – If the future didn’t finish executing before the given timeout.
- result(timeout=None) Any [source]¶
Return the result of the call that the future represents.
- Parameters:
timeout – The number of seconds to wait for the result if the future isn’t done. If None, then there is no limit on the wait time.
- Returns:
The final result
- Raises:
CancelledError – If the future was cancelled.
TimeoutError – If the future didn’t finish executing before the given timeout.