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:
@@ -129,6 +129,15 @@ class XMPPClient:
|
||||
logger.debug(f"[XMPP] Message ignoré (non autorisé) : {sender}")
|
||||
return
|
||||
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:
|
||||
self._message_callback(sender, body, is_muc)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user