Registry / communication / dbus-fast

dbus-fast

JSON →
library5.0.22pypypi✓ verified 24d ago

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.

pip install dbus-fast
INSTALL
IMPORT
SIG · DBUS-FAST
D
dbus-fast
communicationpythonv5.0.22
Install
2.2s avg
Import
292ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.0.22 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.306s · 20.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.278s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MessageBus
from dbus_fast.aio import MessageBus
The primary entry point for asynchronous D-Bus communication.
BusType
from dbus_fast.constants import BusType
Used to specify connection type (SESSION or SYSTEM).
ServiceInterface
from dbus_fast.service import ServiceInterface, method, dbus_property, signal
Essential for defining D-Bus services.
Variant
from dbus_fast import Variant
Represents a D-Bus variant type.

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.

import asyncio from dbus_fast.aio import MessageBus from dbus_fast.constants import BusType async def main(): # Connect to the system bus. For the user session bus, use BusType.SESSION. bus = await MessageBus(bus_type=BusType.SYSTEM).connect() try: reply = await bus.call( bus_name="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface="org.freedesktop.DBus", member="ListNames", ) names = reply.body[0] print("D-Bus names on system bus:", names) except Exception as e: print(f"Error calling ListNames on system bus: {e}") print("Note: Access to the system bus typically requires specific permissions (e.g., being in a 'wheel' group or root).") finally: await bus.disconnect() if __name__ == "__main__": # Ensure this runs in an async context asyncio.run(main())
Debug
Known issues
breakingThe representation of D-Bus STRUCT types changed from Python lists to tuples.
fix
Update your code to expect and process Python tuples for D-Bus STRUCT types. For example, `(item1, item2)` instead of `[item1, item2]`.
affects: <3.0.0
gotchadbus-fast requires Python 3.10 or newer.
fix
Ensure your development and deployment environments are running Python 3.10 or a later version. Upgrade Python if necessary.
affects: All versions
gotchadbus-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.
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.
affects: All versions
gotchaAccessing 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').
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.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named 'dbus_fast'
The 'dbus-fast' library is not installed in the current Python environment, or the environment where the code is being executed cannot locate the installed package.
fix
Ensure 'dbus-fast' is installed using pip: `pip install dbus-fast`. If using virtual environments, activate the correct environment before running the code.
AttributeError: 'Bus' object has no attribute 'get_proxy_object'
This error often occurs when trying to use an API method from a different D-Bus library (e.g., 'dbus-python') or when incorrectly instantiating the MessageBus object. In `dbus-fast`, `get_proxy_object` is a method of the specific asynchronous MessageBus implementations (like `aio.MessageBus` or `glib.MessageBus`), not necessarily a generic 'Bus' object or `BaseMessageBus`.
fix
Ensure you are importing and instantiating the correct `MessageBus` implementation, typically `from dbus_fast.aio import MessageBus` for asyncio, and then use `await bus.get_proxy_object(bus_name, object_path, introspection_xml)`.
dbus_fast.signature.Variant size changed, may indicate binary incompatibility
This specific error message indicates a binary incompatibility or version mismatch within `dbus-fast` or its underlying components, possibly due to a partial upgrade, cached build artifacts, or conflicts with other installed packages, especially if optional Cython extensions are involved.
fix
Reinstall `dbus-fast` cleanly, ideally in a fresh virtual environment: `pip uninstall dbus-fast && pip install dbus-fast`. If the problem persists, try `pip install dbus-fast --no-cache-dir` or consider updating `pip` and `setuptools`.
EOFError
An `EOFError` in the context of `dbus-fast` typically signifies that the D-Bus connection has been unexpectedly closed or terminated by the remote peer or the D-Bus daemon itself, often due to the service crashing, being stopped, or network issues.
fix
Implement robust error handling around D-Bus communication to catch `EOFError` (and `dbus_fast.errors.DBusError`) and logic to gracefully reconnect the `MessageBus` if the connection is lost. Verify the stability and availability of the D-Bus service you are interacting with.
Upgrade
Version history
5.0.22latest on PyPI · released Jun 5, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
22
OpenAI (training)
1
Resources
dbus-fast — pip install dbus-fast · libregistry