V9.0.1: Rainer Quality Gate — 4 P1-Fixes
F1.1: Hook-Adapter-Bridge nutzt offizielle API (Modul-Level _active_adapter
statt privater ctx._adapter/ctx._platforms)
F1.2: Hook-Registrierung in connect()-Lifecycle-Phase (nicht register())
— Adapter ist dann vollständig initialisiert
F1.3: asyncio.Lock lazy-created (Python 3.14 forward-compat)
F2.1: 3 neue 429-Tests (kein Crash, Retry bei nächstem Hook, Telemetrie)
Tests: 39 passed, 99 skipped (V8.x), 0 failed
This commit is contained in:
@@ -87,7 +87,10 @@ class PresenceEngine:
|
||||
|
||||
# ── State-Maschine ────────────────────────────────────────────────
|
||||
self._status: str = "ONLINE" # ONLINE | BUSY
|
||||
self._transition_lock = asyncio.Lock()
|
||||
# F1.3: asyncio.Lock lazy-created to avoid Python 3.14 deprecation.
|
||||
# Creating asyncio.Lock() outside a running event loop is deprecated
|
||||
# in 3.14+. We defer creation to first use (always inside async context).
|
||||
self._transition_lock: Optional[asyncio.Lock] = None
|
||||
|
||||
# ── away-grace: EIN async Task für ONLINE-Transition ──────────────
|
||||
self._away_grace_task: Optional[asyncio.Future] = None
|
||||
@@ -207,6 +210,17 @@ class PresenceEngine:
|
||||
|
||||
# ── Interne State-Maschine ───────────────────────────────────────────
|
||||
|
||||
def _get_lock(self) -> asyncio.Lock:
|
||||
"""Lazy-create asyncio.Lock (F1.3: Python 3.14 forward-compat).
|
||||
|
||||
Creating asyncio.Lock() outside a running event loop is deprecated
|
||||
in Python 3.14+. This method defers creation to first use, which
|
||||
always happens inside an async context (Hook-Callback).
|
||||
"""
|
||||
if self._transition_lock is None:
|
||||
self._transition_lock = asyncio.Lock()
|
||||
return self._transition_lock
|
||||
|
||||
async def _apply_counter_delta(self, counter_name: str, delta: int) -> None:
|
||||
"""Atomar: Counter mutieren, Summe prüfen, ggf. Transition auslösen.
|
||||
|
||||
@@ -217,7 +231,7 @@ class PresenceEngine:
|
||||
if not self._enabled:
|
||||
return
|
||||
|
||||
async with self._transition_lock:
|
||||
async with self._get_lock():
|
||||
# ── Counter mutieren ─────────────────────────────────────────
|
||||
old_value = self.counters[counter_name]
|
||||
new_value = old_value + delta
|
||||
|
||||
Reference in New Issue
Block a user