Chunking stream groups
For an overview, refer to Chunking stream groups. This page is a reference for the Python API. It extends the API for chunks.
- class spead2.recv.ChunkStreamGroupConfig(**kwargs)
Parameters for a chunk stream group. The configuration options can either be passed to the constructor (as keyword arguments) or set as properties after construction.
- Parameters:
max_chunks (int) – The maximum number of chunks that can be live at the same time.
eviction_mode (EvictionMode) – The chunk eviction mode.
- class spead2.recv.ChunkStreamRingGroup(config, data_ringbuffer, free_ringbuffer)
Stream group that uses ringbuffers to manage chunks.
When a fresh chunk is needed, it is retrieved from a ringbuffer of free chunks (the “free ring”). When a chunk is flushed, it is pushed to a “data ring”. These may be shared between groups, but both will be stopped as soon as any of the members streams are stopped. The intended use case is parallel groups that are started and stopped together.
It behaves like a
Sequence
of the contained streams.- Parameters:
config (
spead2.recv.ChunkStreamGroupConfig
) – Group configurationdata_ringbuffer (
spead2.recv.ChunkRingbuffer
) – Ringbuffer onto which the completed chunks are placed.free_ringbuffer (
spead2.recv.ChunkRingbuffer
) – Ringbuffer from which new chunks are obtained.
- data_ringbuffer
The data ringbuffer given to the constructor.
- free_ringbuffer
The free ringbuffer given to the constructor.
- add_free_chunk(chunk)
Add a chunk to the free ringbuffer. This takes care of zeroing out the
Chunk.present
array, and it will suppress thespead2.Stopped
exception if the free ringbuffer has been stopped.If the free ring is full, it will raise
spead2.Full
rather than blocking. The free ringbuffer should be constructed with enough slots that this does not happen.
- emplace_back(thread_pool, config, chunk_stream_config)
Add a new stream.
- Parameters:
thread_pool (
spead2.ThreadPool
) – Thread pool handling the I/Oconfig (
spead2.recv.StreamConfig
) – Stream configurationchunk_config (
spead2.recv.ChunkStreamConfig
) – Chunking configuration
- Return type:
- class spead2.recv.ChunkStreamGroupMember
A component stream in a
ChunkStreamRingGroup
. This class cannot be instantiated directly. UseChunkStreamRingGroup.emplace_back()
instead.It provides the same methods for adding readers as
spead2.recv.Stream
.