mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
[PR #328] [MERGED] Shut down MQTT relay and smart plug services explicitly #998
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy#998
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/maziggy/bambuddy/pull/328
Author: @jeffsf
Created: 2/10/2026
Status: ✅ Merged
Merged: 2/13/2026
Merged by: @maziggy
Base:
0.2.0b← Head:fixes/327📝 Commits (3)
c45568bShut down MQTT relay and smart plug services explicitly2af5289Merge branch '0.2.0b' into fixes/3277c36283Merge branch '0.2.0b' into fixes/327📊 Changes
5 files changed (+32 additions, -10 deletions)
View changed files
📝
backend/app/main.py(+5 -0)📝
backend/app/services/bambu_mqtt.py(+8 -2)📝
backend/app/services/mqtt_relay.py(+7 -2)📝
backend/app/services/mqtt_smart_plug.py(+8 -2)📝
backend/app/services/printer_manager.py(+4 -4)📄 Description
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
Description
Related Issue
Fixes #327
Type of Change
Changes Made
See commit message or above description
Screenshots
Testing
Checklist
Additional Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.