From f71cd0d48da3d2815f21d98a795aca24a087fc52 Mon Sep 17 00:00:00 2001 From: sylvain Date: Thu, 12 Mar 2026 14:30:30 +0000 Subject: [PATCH] feat(mqtt): add unsubscribe() method to MQTTClient Co-Authored-By: Claude Sonnet 4.6 --- agents_core/mqtt_client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agents_core/mqtt_client.py b/agents_core/mqtt_client.py index 929332e..effa164 100644 --- a/agents_core/mqtt_client.py +++ b/agents_core/mqtt_client.py @@ -173,6 +173,13 @@ class MQTTClient: self.client.subscribe(topic, qos=1) logger.debug(f"[{self.agent_id}] Abonné à {topic}") + def unsubscribe(self, topic: str): + """Se désabonner d'un topic.""" + with self._lock: + self._subscriptions.pop(topic, None) + self.client.unsubscribe(topic) + logger.debug(f"[{self.agent_id}] Désabonné de {topic}") + def subscribe_inbox(self, callback: Callable): """S'abonner à sa propre inbox.""" self.subscribe(self.topic_inbox(), callback)