P1c: hasattr-Schutz in connect() — getattr-Pattern statt direktem Attributzugriff
connect() Z.1936: self._gate_sweep_task durch getattr(self, '_gate_sweep_task', None) ersetzt. Beim ersten connect()-Aufruf nach Adapter-Instanziierung existiert _gate_sweep_task noch nicht als Attribut — direkter Zugriff warf AttributeError und connect() brach ab. disconnect() Z.6519 hatte den hasattr-Check bereits. Konsistenz mit disconnect(): gleiches getattr-Pattern (Option 1 nach Rainer). Test: test_connect_fresh_adapter_no_attribute_error - Marker: @pytest.mark.outbound_gate - Verifiziert: connect() auf frischem Adapter (ohne _gate_sweep_task) wirft kein AttributeError und erzeugt _gate_sweep_task korrekt. - Coverage-Lücke geschlossen (Rainer-Review).
This commit is contained in:
+3
-2
@@ -1933,8 +1933,9 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
self._listen_task = asyncio.create_task(self._listen_loop())
|
||||
# P5 V9.x W2: OutboundGate Sweep-Loop (asyncio.create_task, nicht threading.Timer)
|
||||
# ── P1c: Sweep-Task-Check vor Re-create ──
|
||||
if self._gate_sweep_task is not None and not self._gate_sweep_task.done():
|
||||
self._gate_sweep_task.cancel()
|
||||
task = getattr(self, '_gate_sweep_task', None)
|
||||
if task is not None and not task.done():
|
||||
task.cancel()
|
||||
self._gate_sweep_task = asyncio.create_task(self._gate_sweep_loop())
|
||||
self._last_activity = time.time()
|
||||
logger.info("[rocketchat] Listen loop started, _running=%s", self._running)
|
||||
|
||||
Reference in New Issue
Block a user