The full model
Here’s a complete runnable ReactorModel:model.py
Output tracks
Video means the field carries video frames.
You can have multiple tracks:
main_video, main_audio) become the track identifiers that clients use.
The model class
ReactorModel and override the methods you need. The runtime provides emit(), send(), self.connected, and the event dispatcher.
Loading weights
config dict comes from config.yml. This is where you load checkpoints, allocate GPU memory, and set up your pipeline.
The run loop
await self.connected.wait()blocks until a client connects.- The inner loop produces frames and calls
emit()to send them to the client. - When
self.connectedis cleared (client disconnects), the inner loop exits and the outer loop waits for the next client.
run() in detail: emitting frames, batches, backpressure, and adaptive frame rates.
Events
@event for each parameter the client can change.
Lifecycle hooks
@connected runs when a client connects. Use it to initialize per-session state. @disconnected runs when they leave. Use it to clean up buffers and reset resources.
The manifest
reactor.yaml
model: import path inmodule:ClassNameformat.name: human-readable identifier, used in logging and routing.config: path to the model config YAML.
Next
The Run Loop
Emitting frames, batches, backpressure, and adaptive frame rates.
Managing State
Instance attributes, explicit events, and concurrency.