Stream data continuously. Args: generator: Function that returns frame bytes rate_hz: Streaming rate in Hz duration_seconds: Duration to stream (None = infinite)
(
self,
generator: Callable[[], bytes],
rate_hz: float = 10.0,
duration_seconds: Optional[float] = None,
)
| 181 | time.sleep(delay) |
| 182 | |
| 183 | def stream_data( |
| 184 | self, |
| 185 | generator: Callable[[], bytes], |
| 186 | rate_hz: float = 10.0, |
| 187 | duration_seconds: Optional[float] = None, |
| 188 | ) -> None: |
| 189 | """ |
| 190 | Stream data continuously. |
| 191 | |
| 192 | Args: |
| 193 | generator: Function that returns frame bytes |
| 194 | rate_hz: Streaming rate in Hz |
| 195 | duration_seconds: Duration to stream (None = infinite) |
| 196 | """ |
| 197 | interval = 1.0 / rate_hz |
| 198 | start_time = time.time() |
| 199 | |
| 200 | while self._running: |
| 201 | if duration_seconds and (time.time() - start_time) >= duration_seconds: |
| 202 | break |
| 203 | |
| 204 | try: |
| 205 | frame = generator() |
| 206 | self.send_frame(frame) |
| 207 | except Exception: |
| 208 | break |
| 209 | |
| 210 | time.sleep(interval) |
| 211 | |
| 212 | def wait_for_connection(self, timeout: float = 10.0) -> bool: |
| 213 | """ |
nothing calls this directly
no test coverage detected