mirror of
https://github.com/pwr-Solaar/Solaar.git
synced 2026-10-26 16:15:37 +01:00
`solaar show` (and any exit path) printed a cascade of "I/O operation on closed file" / "sys.meta_path is None" logging errors at the bottom. Two compounding causes: - Device.close() was not idempotent. The CLI closes devices explicitly, then __del__ calls close() again during interpreter shutdown, re-running every device cleanup a second time. Guard with a _closed flag (not self.handle, which is legitimately None for receiver-paired devices). - rgb_power.cleanup() read device.settings — the lazy property — which forces a first-time settings build. Running that build during shutdown fails because gettext can no longer import (sys.meta_path is None), raising inside a __del__ handler. Read the already-built settings (or the persister) via a new _rgb_control_off() helper that never triggers the build. Either guard alone stops the crash; both are correct hardening for a __del__-invoked path.