diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b9b16623..34529262 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -21,6 +21,7 @@ Changed Fixed ----- +* Fixed file handle leak in BlueZ backend when D-Bus connection is lost and re-established. * Fixed crash in CoreBluetooth backend if an ObjC delegate callback is called after the asyncio run loop stops. * Fixed possible deadlock when starting scanning on Windows when Bluetooth is turned off. * Fixed "Bluetooth device is turned off" Exception on macOS, when a Bluetooth permission request popup is shown to the user by the OS. diff --git a/bleak/backends/bluezdbus/manager.py b/bleak/backends/bluezdbus/manager.py index ca2c5451..ff87b151 100644 --- a/bleak/backends/bluezdbus/manager.py +++ b/bleak/backends/bluezdbus/manager.py @@ -361,6 +361,11 @@ async def async_init(self) -> None: bus.disconnect() raise + if self._bus: + # Even if we are disconnected, still need to call this to + # release file handles. + self._bus.disconnect() + # Everything is setup, so save the bus self._bus = bus