Skip to content

Commit

Permalink
Remove empty interfaces from BlueZManager._properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Siecje authored and dlech committed Feb 20, 2024
1 parent b7606ed commit ae22bdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Changed
-------
* Updated PyObjC dependency on macOS to v10.x.
* Updated missing Bluetooth SIG characteristics and service UUIDs.
* Updated ``BlueZManager`` to remove empty interfaces from `_properties` during InterfacesRemoved message.

Fixed
-----
Expand Down
6 changes: 6 additions & 0 deletions bleak/backends/bluezdbus/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,12 @@ def _parse_msg(self, message: Message):
del self._descriptor_map[obj_path]
except KeyError:
pass

# Remove empty properties when all interfaces have been removed.
# This avoids wasting memory for people who have noisy devices
# with private addresses that change frequently.
if obj_path in self._properties and not self._properties[obj_path]:
del self._properties[obj_path]
elif message.member == "PropertiesChanged":
interface, changed, invalidated = message.body
message_path = message.path
Expand Down

0 comments on commit ae22bdb

Please sign in to comment.