mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
/camera/stream took its printer row via Depends(get_db). get_db is a yield dependency, so its session stayed open until the response body finished streaming — for a live MJPEG stream, as long as the browser tab is open (hours). Every open camera tile pinned one pooled DB connection idle-in-transaction, draining the pool on large farms. Fetch the printer in a short-lived async_session() and release the connection before returning the StreamingResponse. expire_on_commit= False keeps the already-loaded columns readable during the stream.