# Buggy code
async def connect(self, **kwargs) -> bool:
    """Connect to the specified GATT server.

    Keyword Args:
        timeout (float): Timeout for required ``discover`` call. Defaults to 0.1.

    Returns:
        Boolean representing connection status.

    """

    # A Discover must have been run before connecting to any devices. Do a quick one here
    # to ensure that it has been done.
    await discover(timeout=kwargs.get("timeout", 0.1), loop=self.loop)

    # Create system bus
    self._bus = await txdbus_connect(reactor, busAddress="system").asFuture(self.loop)
    # TODO: Handle path errors from txdbus/dbus
    self._device_path = get_device_object_path(self.device, self.address)

    def _services_resolved_callback(message):
        iface, changed, invalidated = message.body
        is_resolved = defs.DEVICE_INTERFACE and changed.get("ServicesResolved", False)
        if iface == is_resolved:
            logger.info("Services resolved.")
            self.services_resolved = True

    rule_id = await signals.listen_properties_changed(
        self._bus, self.loop, _services_resolved_callback
    )

    logger.debug(
        "Connecting to BLE device @ {0} with {1}".format(self.address, self.device)
    )
    try:
        await self._bus.callRemote(
            self._device_path,
            "Connect",
            interface="org.bluez.Device1",
            destination="org.bluez",
        ).asFuture(self.loop)
    except RemoteError as e:
        raise BleakError(str(e))

    if await self.is_connected():
        logger.debug("Connection successful.")
    else:
        raise BleakError("Connection to {0} was not successful!".format(self.address))

    # Get all services. This means making the actual connection.
    await self.get_services()
    properties = await self._get_device_properties()
    if not properties.get("Connected"):
        raise BleakError("Connection failed!")

    await self._bus.delMatch(rule_id).asFuture(self.loop)
    self._rules["PropChanged"] = await signals.listen_properties_changed(
        self._bus, self.loop, self._properties_changed_callback
    )
    return True


# Traceback (Exception)
Traceback (most recent call last):
File "bug.py", line 25, in <module>
sys.exit(loop.run_until_complete(main(loop)))
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "bug.py", line 19, in main
async with MyInternalStuff(ble_addr="12:34:56:78:90:ab", adapter='hci1', loop=loop):
File "bug.py", line 12, in __aenter__
await self._dev.__aenter__()
File "/home/yggdrasil/.virtualenvs/svhsystemtests/lib/python3.7/site-packages/bleak/backends/client.py", line 41, in __aenter__
await self.connect()
File "/home/yggdrasil/.virtualenvs/svhsystemtests/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 65, in connect
await discover(timeout=0.1, loop=self.loop)
File "/home/yggdrasil/.virtualenvs/svhsystemtests/lib/python3.7/site-packages/bleak/backends/bluezdbus/discovery.py", line 143, in discover
adapter_path, interface = _filter_on_adapter(objects, device)
File "/home/yggdrasil/.virtualenvs/svhsystemtests/lib/python3.7/site-packages/bleak/backends/bluezdbus/discovery.py", line 26, in _filter_on_adapter
raise Exception("Bluetooth adapter not found")
Exception: Bluetooth adapter not found

# Fixed code
async def connect(self, **kwargs) -> bool:
    """Connect to the specified GATT server.

    Keyword Args:
        timeout (float): Timeout for required ``discover`` call. Defaults to 0.1.

    Returns:
        Boolean representing connection status.

    """

    # A Discover must have been run before connecting to any devices. Do a quick one here
    # to ensure that it has been done.
    await discover(
        timeout=kwargs.get("timeout", 0.1), device=self.device, loop=self.loop
    )

    # Create system bus
    self._bus = await txdbus_connect(reactor, busAddress="system").asFuture(self.loop)
    # TODO: Handle path errors from txdbus/dbus
    self._device_path = get_device_object_path(self.device, self.address)

    def _services_resolved_callback(message):
        iface, changed, invalidated = message.body
        is_resolved = defs.DEVICE_INTERFACE and changed.get("ServicesResolved", False)
        if iface == is_resolved:
            logger.info("Services resolved.")
            self.services_resolved = True

    rule_id = await signals.listen_properties_changed(
        self._bus, self.loop, _services_resolved_callback
    )

    logger.debug(
        "Connecting to BLE device @ {0} with {1}".format(self.address, self.device)
    )
    try:
        await self._bus.callRemote(
            self._device_path,
            "Connect",
            interface="org.bluez.Device1",
            destination="org.bluez",
        ).asFuture(self.loop)
    except RemoteError as e:
        raise BleakError(str(e))

    if await self.is_connected():
        logger.debug("Connection successful.")
    else:
        raise BleakError("Connection to {0} was not successful!".format(self.address))

    # Get all services. This means making the actual connection.
    await self.get_services()
    properties = await self._get_device_properties()
    if not properties.get("Connected"):
        raise BleakError("Connection failed!")

    await self._bus.delMatch(rule_id).asFuture(self.loop)
    self._rules["PropChanged"] = await signals.listen_properties_changed(
        self._bus, self.loop, self._properties_changed_callback
    )
    return True