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 python_test.py 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.
Have something to say? You can post a comment by sending an e-Mail to me at <mail@joachim-breitner.de>, and I will include it here.
$ locale
LANG=
LC_CTYPE=fi_FI
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=