diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8806868c..0f9657bf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -21,6 +21,8 @@ Fixed * Fixed reading the battery level returns a zero-filled bytearray on BlueZ >= 5.48. Fixes #750. * Fixed unpairing does not work on windows with winrt. Fixes #699 +* Fixed leak of ``_disconnect_futures`` in ``CentralManagerDelegate``. +* Fixed callback not removed from ``_disconnect_callbacks`` on disconnect in ``CentralManagerDelegate``. `0.14.2`_ (2022-01-26) diff --git a/bleak/backends/corebluetooth/CentralManagerDelegate.py b/bleak/backends/corebluetooth/CentralManagerDelegate.py index 5fc3e6dd..ac83c9f2 100644 --- a/bleak/backends/corebluetooth/CentralManagerDelegate.py +++ b/bleak/backends/corebluetooth/CentralManagerDelegate.py @@ -185,7 +185,7 @@ async def disconnect(self, peripheral: CBPeripheral) -> None: self.central_manager.cancelPeripheralConnection_(peripheral) await future finally: - del self._disconnect_callbacks[peripheral.identifier()] + del self._disconnect_futures[peripheral.identifier()] @objc.python_method def _changed_is_scanning(self, is_scanning: bool) -> None: @@ -353,7 +353,8 @@ def did_disconnect_peripheral( else: future.set_result(None) - callback = self._disconnect_callbacks.get(peripheral.identifier()) + callback = self._disconnect_callbacks.pop(peripheral.identifier(), None) + if callback is not None: callback()