From 1ef2ba3edeb7e092ecf83b4ed0b49836c3fb25ce Mon Sep 17 00:00:00 2001 From: Johannes Hutter Date: Tue, 16 Jul 2019 16:06:58 +0200 Subject: [PATCH] Prevent leaking of DBus connections on discovery During a call to discover() on the Bluez backend, a DBus connection is opened, but never closed. If discover() is called multiple times while the application is running, DBus at some point prevents opening additional connections. Make sure the bus connection is closed after discovery. --- bleak/backends/bluezdbus/discovery.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bleak/backends/bluezdbus/discovery.py b/bleak/backends/bluezdbus/discovery.py index 35546942..906ee109 100644 --- a/bleak/backends/bluezdbus/discovery.py +++ b/bleak/backends/bluezdbus/discovery.py @@ -199,4 +199,7 @@ def parse_msg(message): manufacturer_data = props.get('ManufacturerData', {}) discovered_devices.append(BLEDevice(address, name, {"path": path, "props": props}, uuids=uuids, manufacturer_data=manufacturer_data)) + + bus.disconnect() + return discovered_devices