[packagekit] The dbus backend
Robin Norwood
rnorwood at redhat.com
Mon Feb 11 19:21:16 PST 2008
On Mon, 11 Feb 2008 23:28:06 +0000
Richard Hughes <hughsient at gmail.com> wrote:
> 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.
Wait, it works? Hey, it works! Neat! It wasn't working at all for me
until I read your message and tried again. I guess dbus just needed to
think about things for a bit.
> 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.
Ok, I don't get it. Why keep the text at all if you want ints? Why
not pass everything up the stack as ints, and let the UI translate from
int -> string?
enum.py:
STATUS_CANCEL = 4
STATUS_CLEANUP = 7
yumDBUSbackend.py:
...
self.StatusChanged(STATUS_WAIT)
...
@dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
signature='u')
def StatusChanged(self, status):
print "StatusChanged (%i)" % (status)
Etc.
Or is that basically your idea #1? If so, I'd go with that, except
I don't see why we need to keep the string version around in an enum at
all, except maybe as a map for display in the UI.
-RN
--
Robin Norwood
Red Hat, Inc.
"The Sage does nothing, yet nothing remains undone."
-Lao Tzu, Te Tao Ching
More information about the PackageKit
mailing list