From 730ef56425bce1f1c2371b05c1b01b030405f7ad Mon Sep 17 00:00:00 2001 From: Cody Scott Date: Tue, 3 Sep 2024 09:18:56 -0400 Subject: [PATCH] Handle when transport has been garbage collected. --- azure-iot-device/azure/iot/device/common/mqtt_transport.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-iot-device/azure/iot/device/common/mqtt_transport.py b/azure-iot-device/azure/iot/device/common/mqtt_transport.py index cf54a0416..200f0570c 100644 --- a/azure-iot-device/azure/iot/device/common/mqtt_transport.py +++ b/azure-iot-device/azure/iot/device/common/mqtt_transport.py @@ -190,6 +190,10 @@ def on_connect(client, userdata, flags, rc): logger.warning( "connection failed, but no on_mqtt_connection_failure_handler handler callback provided" ) + elif not this: + logger.info( + "on_connect called with transport==None. Transport must have been garbage collected. stopping loop" + ) elif this.on_mqtt_connected_handler: try: this.on_mqtt_connected_handler()