INNER CODE UNIT · Python
_open_aoi_store
marc-shade/world-intel-mcp · src/world_intel_mcp/dashboard/app.py:105
def _open_aoi_store() -> AOIStore:
"""Open the AOI store on the same cache database the MCP server and
CLI write geofences to, so the map shows exactly the areas a user
defined over MCP.
Opened per request and closed by the caller, never cached: SQLite
connections are bound to the thread that created them, and a
module-level store built on one thread and read from another (the
test client's portal thread; any ``to_thread`` path) raises. A
fresh connection per read is cheap and thread-safe by construction,
the same pattern ``analysis.aoi.fetch_aoi_sweep`` uses."""
return AOIStore(_ensure_fetcher().cache.db_path)
# ---------------------------------------------------------------------------
# Data fetching
# ---------------------------------------------------------------------------