Skip to content

fix: Add proper cleanup for MQTT client connections#611

Open
cjb0001 wants to merge 66 commits intoMyElectricalData:mainfrom
cjb0001:fix/mqtt-client-memory-leak
Open

fix: Add proper cleanup for MQTT client connections#611
cjb0001 wants to merge 66 commits intoMyElectricalData:mainfrom
cjb0001:fix/mqtt-client-memory-leak

Conversation

@cjb0001
Copy link

@cjb0001 cjb0001 commented Nov 20, 2025

  • Add disconnect() method to properly stop background threads
  • Add del destructor as safety net for cleanup
  • Add context manager support (enter/exit)
  • Update HomeAssistant class to cleanup MQTT on exit
  • Update ExportMqtt class to cleanup MQTT on exit

This fixes a memory leak where MQTT client background threads were never stopped, causing thread and memory accumulation over time.

Fixes: Memory leak in long-running deployments

hotfix31 and others added 30 commits April 23, 2024 16:12
…uxdb-production-only

fix export to influxdb for production
…work-database

BREAKING CHANGE: database rework
BREAKING CHANGE: Release 1.0.0 with database rework

- Upgrade FastAPI to latest (0.111.0)
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
…ild-args

fix: build arg + downgrade python to 3.11.9 (armv7 bug)
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
m4dm4rtig4n and others added 28 commits July 29, 2024 13:23
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
- Add disconnect() method to properly stop background threads
- Add __del__ destructor as safety net for cleanup
- Add context manager support (__enter__/__exit__)
- Update HomeAssistant class to cleanup MQTT on exit
- Update ExportMqtt class to cleanup MQTT on exit

This fixes a memory leak where MQTT client background threads
were never stopped, causing thread and memory accumulation over time.

Fixes: Memory leak in long-running deployments
@m4dm4rtig4n
Copy link
Collaborator

Hello cjb0001, merci mais je suis en train de réécrire complètement le code de MyElectricalData.
Et le code ici est du coup dépréciée, je ne vais plus forcément le maintenir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants