mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-09 15:35:39 +02:00
Existing code did not allow the MQTT relay to be shut down gracefully. Moved _client.loop_stop() after _client.disconnect() call to allow Paho to be notified to disconnect and shut down without reconnecting. Added _client._disconnection_event to help prevent a race condition where a disconnection is requested but the loop is immediately stopped. Modify _client.disconnect() to take a timeout parameter (default: 0). Wait in that routine for the disconnection event with the given timeout. Apply same logic to MQTTSmartPlugService and add to shutdown sequence. Shutdown the MQTT relay last in lifespan() with a hard-coded 2 sec timeout. The disconnect timeout is also available to printer MQTT clients. It is left to the default of 0 at this time. If later enabled, it should be a configuration parameters, especially for large farms. Fixes: #327 Signed-off-by: Jeff Kletsky <git-commits@allycomm.com>