V9.0.1: Sync-Hooks — invoke_hook() limitation fix
Root Cause: invoke_hook() im Core ruft Callbacks synchron auf (ret = cb(**kwargs)). Async-Callbacks wurden als Coroutine-Objekt zurückgegeben aber nie awaited → Hook-Code wurde NIE ausgeführt. Symptom: Andreas sah immer nur GRÜN (Hooks registriert, feuerten nie). Änderungen: - presence_engine.py: Alle Hook-Callbacks synchron (kein async/await) - Counter-Mutation unter threading.Lock (statt asyncio.Lock) - REST-Calls via fire-and-forget Daemon-Threads (statt asyncio.create_task) - away-grace via threading.Timer (statt asyncio.Task) - _rest_set_status() synchron (urllib ist von Natur aus sync) - __init__.py: Wrapper-Funktionen synchron (kein async def) - adapter.py: bind_loop() für PresenceEngine entfernt (nicht mehr nötig) - Tests: Alle 39 V9-Tests auf sync umgestellt (kein asyncio, kein await) Tests: 39 passed, 82 skipped in 3.24s
This commit is contained in:
+13
-17
@@ -1691,20 +1691,18 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
self._rooms = self.rest.get_rooms()
|
||||
logger.info("[rocketchat] REST get_rooms returned %d rooms", len(self._rooms))
|
||||
|
||||
# V9: Bind asyncio loop to PresenceEngine
|
||||
# V9: Bind asyncio loop to DDP (PresenceEngine braucht keinen Loop mehr — sync Hooks)
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
self.ddp.bind_loop(loop)
|
||||
if hasattr(self, '_presence_engine') and self._presence_engine is not None:
|
||||
self._presence_engine.bind_loop(loop)
|
||||
logger.info(
|
||||
"[rocketchat] V9: PresenceEngine loop-bound: yes (loop=%s)",
|
||||
id(loop),
|
||||
)
|
||||
logger.info(
|
||||
"[rocketchat] V9: DDP loop-bound: yes (loop=%s)",
|
||||
id(loop),
|
||||
)
|
||||
except RuntimeError:
|
||||
# No running event loop (e.g., in tests) — graceful degradation
|
||||
logger.info(
|
||||
"[rocketchat] V9: PresenceEngine loop-bound: no "
|
||||
"[rocketchat] V9: DDP loop-bound: no "
|
||||
"(no running event loop)"
|
||||
)
|
||||
|
||||
@@ -1991,20 +1989,18 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
self.user = resolved.lower()
|
||||
logger.info("[rocketchat] Resolved self.user from login (reconnect): %s", self.user)
|
||||
|
||||
# V9: Re-bind asyncio loop to PresenceEngine
|
||||
# V9: Re-bind asyncio loop to DDP (PresenceEngine braucht keinen Loop mehr — sync Hooks)
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
self.ddp.bind_loop(loop)
|
||||
if hasattr(self, '_presence_engine') and self._presence_engine is not None:
|
||||
self._presence_engine.bind_loop(loop)
|
||||
logger.info(
|
||||
"[rocketchat] V9: PresenceEngine loop-bound: yes "
|
||||
"(reconnect, loop=%s)",
|
||||
id(loop),
|
||||
)
|
||||
logger.info(
|
||||
"[rocketchat] V9: DDP loop-bound: yes "
|
||||
"(reconnect, loop=%s)",
|
||||
id(loop),
|
||||
)
|
||||
except RuntimeError:
|
||||
logger.info(
|
||||
"[rocketchat] V9: PresenceEngine loop-bound: no "
|
||||
"[rocketchat] V9: DDP loop-bound: no "
|
||||
"(reconnect, no running event loop)"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user