{"id":6875,"library":"sdbus","title":"sdbus","description":"sdbus is a modern, asynchronous Python D-Bus library built upon `sd-bus` from `libsystemd`. It provides a robust, low-level interface for D-Bus communication, supporting both system and session buses. Currently at version 0.14.2, it maintains an active release cycle with regular updates addressing bug fixes and feature enhancements.","status":"active","version":"0.14.2","language":"en","source_language":"en","source_url":"https://github.com/python-sdbus/python-sdbus/","tags":["dbus","inter-process-communication","systemd","asyncio","ipc"],"install":[{"cmd":"pip install sdbus","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"SystemBus","correct":"from sdbus.bus import SystemBus"},{"symbol":"SessionBus","correct":"from sdbus.bus import SessionBus"},{"symbol":"DbusInterface","correct":"from sdbus import DbusInterface"},{"symbol":"dbus_method","correct":"from sdbus import dbus_method"},{"symbol":"dbus_property","correct":"from sdbus import dbus_property"}],"quickstart":{"code":"import sdbus\nimport asyncio\n\nclass MyService(sdbus.DbusInterface):\n    DBUS_NAME = \"org.example.MyService\"\n    DBUS_PATH = \"/org/example/MyObject\"\n    DBUS_INTERFACE = \"org.example.MyInterface\"\n\n    @sdbus.dbus_method\n    def SayHello(self, name: str) -> str:\n        return f\"Hello, {name}!\"\n\nasync def main():\n    # Connect to the System Bus\n    bus = await sdbus.bus.SystemBus().connect()\n    \n    # Export an instance of MyService\n    service_object = MyService()\n    bus.export(service_object)\n    \n    # Request a D-Bus name for the service\n    await bus.request_name(MyService.DBUS_NAME)\n    \n    print(f\"Service '{MyService.DBUS_NAME}' exported on path '{MyService.DBUS_PATH}'.\")\n    print(\"To test, run in another terminal (with busctl):\")\n    print(f\"busctl call {MyService.DBUS_NAME} {MyService.DBUS_PATH} {MyService.DBUS_INTERFACE} SayHello s 'World'\")\n    print(\"Press Ctrl+C to exit.\")\n    \n    # Keep the service running indefinitely\n    await asyncio.Event().wait()\n\nif __name__ == \"__main__\":\n    try:\n        asyncio.run(main())\n    except KeyboardInterrupt:\n        print(\"\\nService stopped.\")\n","lang":"python","description":"This quickstart demonstrates how to create and export a simple D-Bus service using `sdbus`. It connects to the SystemBus, defines an interface with a method, exports an instance of that interface, and requests a D-Bus name, keeping the service alive until interrupted. This allows other D-Bus clients to call its methods."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later. If you must use Python 3.8, pin your sdbus version to `<0.14.0` (e.g., `sdbus<0.14.0`).","message":"Starting with version 0.14.0, sdbus requires Python 3.9 or higher. Version 0.13.0 was the last to support Python 3.8.","severity":"breaking","affected_versions":">=0.14.0"},{"fix":"Explicitly manage your bus connections. Ensure you're connecting and using `SystemBus()` or `SessionBus()` instances as intended, rather than relying on implicit context-local behavior for the default bus.","message":"In version 0.14.0, the default bus handling was changed. Previously, context-local variables were used, often leading to new buses being opened unnecessarily. This might change behavior if your application implicitly relies on the old context-local default bus mechanism.","severity":"gotcha","affected_versions":">=0.14.0"},{"fix":"Review your code for direct usage of `sdbus`'s internal, undocumented APIs. Update your code to use the officially documented public API. Using a type checker like `mypy` can help identify affected areas.","message":"Version 0.12.0 significantly reworked internal undocumented classes and functions. If your code directly interacted with these internal APIs, it might break.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Ensure your system meets the `glibc` and `pip` version requirements if you rely on binary wheels. If not, you might need to compile `sdbus` from source, or use an older `sdbus` version.","message":"For binary PyPI wheels of version 0.14.0 and later, there are increased minimum requirements: glibc 2.28+ (e.g., Debian 10+, Ubuntu 18.10+, RHEL/CentOS 8+) and pip 20.3+.","severity":"breaking","affected_versions":">=0.14.0"},{"fix":"Upgrade to sdbus 0.14.2 or newer to prevent potential segmentation faults when managing object lifetimes, especially in scenarios where exported objects might be garbage collected before their corresponding D-Bus handles.","message":"Version 0.14.2 fixed a segmentation fault that occurred if an export handle outlived the exported object. Older versions might crash under these specific circumstances.","severity":"gotcha","affected_versions":"<0.14.2"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}