add probatory exception trigger in mqtt connection handling
All checks were successful
Build Container / Build Container (push) Successful in 4m15s

This commit is contained in:
lilly 2026-12-01 18:29:12 +01:00
commit 300e773ccd
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g

View file

@ -3,14 +3,13 @@
# https://github.com/eclipse-paho/paho.mqtt.python/blob/master/examples/loop_asyncio.py
#
from typing import Any, Set, Iterable
import logging
import asyncio
import logging
import socket
from typing import Any, Iterable, Set
import paho.mqtt.client as mqtt
logger = logging.getLogger(__name__)
@ -109,9 +108,20 @@ class AsyncMqttClient:
properties: mqtt.Properties,
):
logger.debug(f"mqtt client disconnected with message '{reason_code}'")
if self.fut_disconnect:
self.fut_disconnect.set_result(None)
# this should not be needed since we have an on_connect_fail callback but logs suggest it to be needed
# TODO: investigate whether dooris is now more able to keep its connections
if self.fut_connected is not None:
logger.debug(
f"triggering exceptional failure in connection future from disconnect. this shouldn't happen."
)
self.fut_connected.set_exception(
Exception("mqtt client could not connect to broker")
)
def on_message(self, client: mqtt.Client, userdata: Any, msg: mqtt.MQTTMessage):
self.messages.put_nowait(msg)