fix: dispatch XMPP message callback in thread to avoid blocking asyncio loop

The LLM call (up to 300s) was blocking the slixmpp asyncio event loop,
preventing keepalive pings and causing the server to close the connection.
All XMPP message handling now runs in a daemon thread.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 16:44:59 +00:00
parent 654e238d7e
commit 8a6432e5f8
+9
View File
@@ -129,6 +129,15 @@ class XMPPClient:
logger.debug(f"[XMPP] Message ignoré (non autorisé) : {sender}") logger.debug(f"[XMPP] Message ignoré (non autorisé) : {sender}")
return return
if self._message_callback: if self._message_callback:
# Dispatch dans un thread pour ne pas bloquer la boucle asyncio XMPP
threading.Thread(
target=self._dispatch_callback,
args=(sender, body, is_muc),
daemon=True,
name="xmpp-handler",
).start()
def _dispatch_callback(self, sender: str, body: str, is_muc: bool):
try: try:
self._message_callback(sender, body, is_muc) self._message_callback(sender, body, is_muc)
except Exception as e: except Exception as e: