Talk Preparation: systemd’s D-Bus Implementation, And Its Python asyncio Binding#
- Slides: systemd’s D-Bus Implementation, And Its Python 
asyncioBinding- TL;DR
 - Show
 - A Big Picture
 - Sample Client (
sdbus, Blocking) - Defining Interfaces, Pythonically
 - History/Implementations/Bindings ⟶ 
sdbus - Concrete Use Case: 
jf-irrigation - Irrigation Client: Enter 
asyncio - First Step: Create Proxy
 - Naive try: Use Async Definition To Block
 - Fix: Async Machinery
 - Create Irrigator Proxies
 - Print Statistics
 - D-Bus Signals
 - And Parallelism?
 - Introduce 
asyncio.TaskGroup - Keep In Mind …
 - More 
asyncio 
 
Old Stuff, Random Notes#
D-Bus Show#
Monitoring/Debugging
$ dbus-monitor --session
D-Bus Spec, Implementations#
What is D-Bus: Blah protocol and type system https://dbus.freedesktop.org/doc/dbus-specification.html
jjj draw sketch jf-irrigation
Very good D-Bus intro: Poettering: The new sd-bus API of systemd
D-Bus reference implementation https://www.freedesktop.org/wiki/Software/dbus/
Python binding https://dbus.freedesktop.org/doc/dbus-python/
Really old and quirky, cannot remember
Glib’s D-Bus implementation
gdbuscommandline tool, https://gnome.pages.gitlab.gnome.org/libsoup/gio/gdbus.htmlPython binding LEW21/pydbus
Interfaces defined in XML, pretty weird. Show jfasch/openheating
SD-Bus
What else? bring this at the end
Client Implementation#
Bus name (service name):
me.faschingbauer.IrrigationServiceObject path:
/me/faschingbauer/IrrigationSystemInterface name:
me.faschingbauer.IrrigationSystem, as parameter ofDBusIrrigationSystem(see jfasch/jf-irrigation)Irrigation system
Simple: blocking operations
Structure/objects ⟶ sketch
Challenge: expose objects via D-Bus. Continue irrigation in the “background” while serving D-Bus operations. No-go: create a thread.
Read doc: https://python-sdbus.readthedocs.io/en/latest/examples.html
Gotchas, Weirdnesses#
D-Bus methods (and properties) are always BiCapitalized; if you name a method
some_method, SDBus will translate it toSomeMethodDBus socket is watched somehow magically. in
main(), I’d expect I have to create a task for DBus traffic - but no. Must be done magically inside some of the routines that we use to export object and register names.complain about confusion: busname, path, and iface name
What Else?#
Irrigation Outlook#
Hardware, finally
User interface with textual
Add logging, error reporting, watchdog