refactor(nws): remove internal AsyncLimiter rate limiting

The NWSAdapter had an internal AsyncLimiter that duplicated the
supervisor's rate-limit guarantee. When cadence changed, only
state.adapter.cadence_s was updated, not the internal limiter,
causing the cadence-decrease bug.

Since the supervisor already enforces rate limiting via
last_completed_poll + cadence_s scheduling, the adapter-level
limiter was redundant and caused the 30-second blocking observed
in diagnostic logs.

Removes:
- aiolimiter import
- self.cadence_s attribute (unused elsewhere)
- self._limiter creation
- async with self._limiter context in _fetch_alerts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson 2026-05-16 17:17:11 +00:00
commit 9d4ba97537

View file

@ -10,7 +10,6 @@ from pathlib import Path
from typing import Any
import aiohttp
from aiolimiter import AsyncLimiter
from tenacity import (
retry,
stop_after_attempt,
@ -199,11 +198,9 @@ class NWSAdapter(SourceAdapter):
cursor_db_path: Path,
) -> None:
self.config = config
self.cadence_s = config.cadence_s
self.states = set(s.upper() for s in config.states)
self.cursor_db_path = cursor_db_path
self._session: aiohttp.ClientSession | None = None
self._limiter = AsyncLimiter(1, config.cadence_s)
self._db: sqlite3.Connection | None = None
async def startup(self) -> None:
@ -329,7 +326,6 @@ class NWSAdapter(SourceAdapter):
)
async def _fetch_alerts(self) -> tuple[int, dict[str, Any] | None, str | None]:
"""Fetch alerts from NWS API with conditional request."""
async with self._limiter:
if not self._session:
raise RuntimeError("Session not initialized")