From 509911f5c5ae33605e144803a0a70cd83ca96b9c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Apr 2026 21:51:40 +0000 Subject: [PATCH] feat(03-03): integrate UDPSender into FastAPI lifespan - Import UDPSender in main.py - Start UDPSender on app boot, assign to app.state.udp_sender - Stop UDPSender cleanly on shutdown (before registry.save) - All existing lifespan behavior unchanged (beats, registry, show_store) --- lightsync/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightsync/main.py b/lightsync/main.py index 6f1ed8b..b3e7d9d 100644 --- a/lightsync/main.py +++ b/lightsync/main.py @@ -7,6 +7,7 @@ from fastapi.staticfiles import StaticFiles from lightsync.devices.registry import DeviceRegistry from lightsync.store.show_store import ShowStore +from lightsync.protocol.udp_sender import UDPSender # Module-level containers populated in lifespan registry: DeviceRegistry | None = None @@ -25,9 +26,15 @@ async def lifespan(app: FastAPI): # Beat analysis cache: filepath -> {"tempo": float, "beats": [float, ...]} app.state.beats = {} + # UDP sender for device communication (Phase 3) + udp_sender = UDPSender() + await udp_sender.start() + app.state.udp_sender = udp_sender + yield # Shutdown + await app.state.udp_sender.stop() await registry.save()