mirror of
https://github.com/zvx-echo6/central.git
synced 2026-05-22 02:24:38 +02:00
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:
parent
6deccf1cf8
commit
9d4ba97537
1 changed files with 31 additions and 35 deletions
|
|
@ -10,7 +10,6 @@ from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiolimiter import AsyncLimiter
|
|
||||||
from tenacity import (
|
from tenacity import (
|
||||||
retry,
|
retry,
|
||||||
stop_after_attempt,
|
stop_after_attempt,
|
||||||
|
|
@ -199,11 +198,9 @@ class NWSAdapter(SourceAdapter):
|
||||||
cursor_db_path: Path,
|
cursor_db_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.config = config
|
self.config = config
|
||||||
self.cadence_s = config.cadence_s
|
|
||||||
self.states = set(s.upper() for s in config.states)
|
self.states = set(s.upper() for s in config.states)
|
||||||
self.cursor_db_path = cursor_db_path
|
self.cursor_db_path = cursor_db_path
|
||||||
self._session: aiohttp.ClientSession | None = None
|
self._session: aiohttp.ClientSession | None = None
|
||||||
self._limiter = AsyncLimiter(1, config.cadence_s)
|
|
||||||
self._db: sqlite3.Connection | None = None
|
self._db: sqlite3.Connection | None = None
|
||||||
|
|
||||||
async def startup(self) -> 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]:
|
async def _fetch_alerts(self) -> tuple[int, dict[str, Any] | None, str | None]:
|
||||||
"""Fetch alerts from NWS API with conditional request."""
|
"""Fetch alerts from NWS API with conditional request."""
|
||||||
async with self._limiter:
|
|
||||||
if not self._session:
|
if not self._session:
|
||||||
raise RuntimeError("Session not initialized")
|
raise RuntimeError("Session not initialized")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue