[packagekit] The dbus backend

Richard Hughes hughsient at gmail.com
Mon Feb 11 15:28:06 PST 2008


rnorwood and I have been working on the yum2 dbus backend. I've actually
got the yum2 backend to run now, with search times down from 3 seconds
to 0.7 seconds. So quite a dramatic speedup. Good stuff to look forward
to.

What I really want to do is emit the enumerated values up the stack as
numeric types. This poses a problem for python I think:

enum.py:
STATUS_CANCEL = "cancel"
STATUS_CLEANUP = "cleanup"

yumDBUSbackend.py:
...
    self.StatusChanged(STATUS_WAIT)
...
    @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
                         signature='u')
    def StatusChanged(self, status):
        print "StatusChanged (%i)" % (status)

So, the dbus interface is expecting an integer back (corresponding to
src/pk-common.h) and python is passing back a string, hence boom.

So we have two ways to do this:

enum.py:
STATUS_CANCEL_ID = 4
STATUS_CLEANUP_ID = 7
STATUS_CANCEL = "cancel"
STATUS_CLEANUP = "cleanup"

yumDBUSbackend.py:
...
    self.StatusChanged(STATUS_WAIT_ID)
...
    @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
                         signature='u')
    def StatusChanged(self, status):
        print "StatusChanged (%i)" % (status)

This is the most efficient way, although needs a whole set of new
constants, although, these are trivially autogenerated using Toms magic
generator.

Or, we could just send text and parse the text back into enumerated
types in the deamon, albeit with a speed penalty.

There's no API or ABI guarantees for DBUS modules for IPC (shoulnd't be
built out of tree), so I'm not scared of using raw uint32 numbers.

So, do we be efficient and pass back integers (risking ABI breakage), or
do it belt and braces and parse each one in the daemon.

Comments welcome.

Richard.





More information about the PackageKit mailing list