Skip to content

Commit 6c3c294

Browse files
committed
backends/bluezdbus/manager: Release resources on bus restart
Call disconnect() on the old bus object if we have to reconnect to the D-Bus system bus. This ensures that file handles are released and we don't leak them.
1 parent a6fea5a commit 6c3c294

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Changed
2121

2222
Fixed
2323
-----
24+
* Fixed file handle leak in BlueZ backend when D-Bus connection is lost and re-established.
2425
* Fixed crash in CoreBluetooth backend if an ObjC delegate callback is called after the asyncio run loop stops.
2526
* Fixed possible deadlock when starting scanning on Windows when Bluetooth is turned off.
2627
* Fixed "Bluetooth device is turned off" Exception on macOS, when a Bluetooth permission request popup is shown to the user by the OS.

bleak/backends/bluezdbus/manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ async def async_init(self) -> None:
361361
bus.disconnect()
362362
raise
363363

364+
if self._bus:
365+
# Even if we are disconnected, still need to call this to
366+
# release file handles.
367+
self._bus.disconnect()
368+
364369
# Everything is setup, so save the bus
365370
self._bus = bus
366371

0 commit comments

Comments
 (0)