{"id":3954,"library":"dbus-fast","title":"dbus-fast","description":"dbus-fast is a high-performance Python library for interacting with the D-Bus message bus, providing an asynchronous API built on `asyncio`. It aims to be a faster and more modern alternative to older D-Bus libraries, focusing on speed and comprehensive type-hinting support. Currently at version 4.0.4, it maintains a rapid release cadence with frequent updates and bug fixes.","status":"active","version":"4.0.4","language":"en","source_language":"en","source_url":"https://github.com/bluetooth-devices/dbus-fast","tags":["dbus","asyncio","ipc","interprocess","linux"],"install":[{"cmd":"pip install dbus-fast","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The primary entry point for asynchronous D-Bus communication.","symbol":"MessageBus","correct":"from dbus_fast.aio import MessageBus"},{"note":"Used to specify connection type (SESSION or SYSTEM).","symbol":"BusType","correct":"from dbus_fast.constants import BusType"},{"note":"Essential for defining D-Bus services.","symbol":"ServiceInterface","correct":"from dbus_fast.service import ServiceInterface, method, dbus_property, signal"},{"note":"Represents a D-Bus variant type.","symbol":"Variant","correct":"from dbus_fast import Variant"}],"quickstart":{"code":"import asyncio\nfrom dbus_fast.aio import MessageBus\nfrom dbus_fast.constants import BusType\n\nasync def main():\n    # Connect to the system bus. For the user session bus, use BusType.SESSION.\n    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()\n\n    try:\n        reply = await bus.call(\n            bus_name=\"org.freedesktop.DBus\",\n            path=\"/org/freedesktop/DBus\",\n            interface=\"org.freedesktop.DBus\",\n            member=\"ListNames\",\n        )\n        names = reply.body[0]\n        print(\"D-Bus names on system bus:\", names)\n    except Exception as e:\n        print(f\"Error calling ListNames on system bus: {e}\")\n        print(\"Note: Access to the system bus typically requires specific permissions (e.g., being in a 'wheel' group or root).\")\n    finally:\n        await bus.disconnect()\n\nif __name__ == \"__main__\":\n    # Ensure this runs in an async context\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to connect to the D-Bus system bus and call the standard `ListNames` method on the D-Bus daemon. It prints the names of currently registered services. Remember to run this in an `asyncio` event loop."},"warnings":[{"fix":"Update your code to expect and process Python tuples for D-Bus STRUCT types. For example, `(item1, item2)` instead of `[item1, item2]`.","message":"The representation of D-Bus STRUCT types changed from Python lists to tuples.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Ensure your development and deployment environments are running Python 3.10 or a later version. Upgrade Python if necessary.","message":"dbus-fast requires Python 3.10 or newer.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always `await` calls to `MessageBus` methods (e.g., `bus.connect()`, `bus.call()`) and ensure your main script uses `asyncio.run()` or similar `asyncio` entry points.","message":"dbus-fast is an asynchronous library and requires careful use of `async`/`await` within an `asyncio` event loop. Forgetting `await` or not running in a loop will lead to errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For system bus interactions, ensure the running user has the necessary permissions. Test with `BusType.SESSION` if you only need to interact with user-level services.","message":"Accessing the D-Bus system bus (BusType.SYSTEM) often requires specific user permissions or group memberships, which can lead to `dbus_fast.errors.DbusError` (e.g., 'org.freedesktop.DBus.Error.AccessDenied').","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}