mux
MuxedData
dataclass
MuxedData(time, data)
Muxer
Muxer(keys, start=None, timeout=DEFAULT_TIMEOUT)
Bases: Generic[T]
A data structure that multiplexes items from multiple named streams.
Given items from multiple named streams with monotonically increasing integer timestamps, this data structure can be used to pull out sets of synchronized items (items all with the same timestamp).
The oldest items will be held until either all named streams are available or until the timeout has been reached. If a start time has been set, any items with an older timestamp will be rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Iterable[str]
|
Identifiers for the named streams to expect when adding items. |
required |
start
|
int
|
The GPS time to start muxing items for. If not set, accept items from any time. |
None
|
timeout
|
timedelta or None
|
The maximum time to wait for messages from named streams, in seconds, before multiplexing. If None is specified, wait indefinitely. Default is 1 second. |
DEFAULT_TIMEOUT
|
Source code in arrakis/mux.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
pull
pull()
Pull monotonically increasing synchronized items from the muxer.
Yields:
| Type | Description |
|---|---|
MuxedData[T]
|
Synchronized items with a common timestamp, keyed by stream keys. |
Source code in arrakis/mux.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
push
push(time, key, item, on_drop='warn')
Push an item into the muxer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
int
|
The timestamp associated with this item. |
required |
key
|
str
|
The key stream associated with this item. Must match a key provided at initialization. |
required |
item
|
T
|
The item to add. |
required |
on_drop
|
str
|
Specifies behavior when the item would be dropped from the muxer, in the case that it was not provided to the muxer before the specified timeout. Options are 'ignore', 'raise', or 'warn'. Default is 'warn'. |
'warn'
|
Source code in arrakis/mux.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |