Joachim Breitner

Reliability testing for python-dbus applications

Published 2009-02-12 in sections English, Digital World.

In the Openmoko community, a lot of programs are written in python and use services provided over D-Bus. But I’m under the impression that not enough programmers consider that D-Bus is a remote protocol, and the other side might fail to respond any time. The code then works find if nothing goes wrong, but does not handle problems well. Understandably, it is hard to get this error checking right if you can’t really test it, as usually the D-Bus services do not fail. This is particularly annoying on a phone, because it might just be the program responsible for popping up the on screen keyboard that just failed.

Therefore I started to write a little python module called that replaces some D-Bus functions in the python bindings (SystemBus.get_object and Connection.call_blocking at the moment) and makes them fail with a certain probability. You can add "import dbus_test" to your program (and adjust $PYTHON_PATH) and run it a few times, to see which error conditions are caught and which cause your problem to fail. If you come across failures that the script does not yet generate, they can easily be added.

Not sure yet if I am going to extend and maintain this, but I’m open to suggestions and additions. Maybe this (or something similar) should be provided by python-dbus directly.


SyntaxError: Non-ASCII character '\xc2' in file /home/lindi/ on line 4, but no encoding declared; see for details

$ locale
#1 Timo Lindfors am 2009-02-13
Thanks for the pointer, I’ve added the utf8 encoding mark to the script.
#2 Joachim Breitner (Homepage) am 2009-02-13

Have something to say? You can post a comment by sending an e-Mail to me at <>, and I will include it here.