[packagekit] Question about pk_backend_thread_helper ()

Richard Hughes hughsient at gmail.com
Wed Nov 28 12:58:59 PST 2007


On Tue, 2007-11-27 at 16:31 -0700, Boyd Timothy wrote:
> I recall reading something that our backends should spawn threads to
> do heavy lifting so they don't block the UI.  Today I've been adding
> code to add progress information to the zypp backend.  Unfortunately,
> it doesn't appear that the pk_backend_thread_helper() is doing what it
> ought to do.

After testing this, I totally agree with you!

> I noticed that pk_backend_thread_helper () actually joins the spawned
> thread and waits for it to finished.  If this is what's happening, how
> does that allow the GUI to continue on?  Using this function, my
> progress information is not being reflected in the UI
> ("pk-install-package lynx" or "pkcon install lynx").  At the very end
> after the package has been downloaded and installed, the UI will
> quickly display at 100% before quitting.

We certainly shouldn't be joining the thread at this point, else there's
no point in the thread at all! :-)

> So, I've experimented with pk_backend_create_thread () instead.  Using
> this fuction, the GUI now responds to my progress updates.  But, of
> course, now the GUI never receives a pk_backend_finished () message,
> so it never exits.  Trying to be smart, I added pk_backend_finished ()
> to my install thread, but now the pk-daemon is complaining at me.

Well, that's probably what we should do, i.e. use
pk_backend_create_thread() and then just do pk_backend_finished() when
the thread is done.

> What is the magic trick to make threading with progress updates work?
> I've pushed all my ugly code up to git in case you want to look at the
> mess.  :)

Code looks fine, no need to self-deprecate... Let me throw some code
into git.

Richard.





More information about the PackageKit mailing list