Location
router/main.py (inside get_dashboard endpoint, line 2180)
Problem Description
The /dashboard endpoint calls get_goose_sessions() synchronously. Because get_goose_sessions performs blocking disk reading operations against the SQLite database (sessions.db), it halts the entire asyncio event loop thread. Under load, this creates critical request-routing latency spikes for other endpoints since the single event loop thread is blocked.
Fix Overview
Offload the synchronous SQLite database interaction to a worker thread using asyncio.to_thread.
Proposed Implementation Steps
- Open
router/main.py.
- Find
get_dashboard endpoint.
- Locate
goose_sessions = get_goose_sessions() (around line 2180).
- Change it to:
goose_sessions = await asyncio.to_thread(get_goose_sessions).
Code Example / Diff
@@ -2179,3 +2179,3 @@
# 2. Query Goose Sessions SQLite DB
- goose_sessions = get_goose_sessions()
+ goose_sessions = await asyncio.to_thread(get_goose_sessions)
Location
router/main.py(insideget_dashboardendpoint, line 2180)Problem Description
The
/dashboardendpoint callsget_goose_sessions()synchronously. Becauseget_goose_sessionsperforms blocking disk reading operations against the SQLite database (sessions.db), it halts the entire asyncio event loop thread. Under load, this creates critical request-routing latency spikes for other endpoints since the single event loop thread is blocked.Fix Overview
Offload the synchronous SQLite database interaction to a worker thread using
asyncio.to_thread.Proposed Implementation Steps
router/main.py.get_dashboardendpoint.goose_sessions = get_goose_sessions()(around line 2180).goose_sessions = await asyncio.to_thread(get_goose_sessions).Code Example / Diff