[packagekit] Run pkclient action from thread
Matthias Klumpp
matthias at nlinux.org
Fri Apr 16 11:00:13 PDT 2010
Hi!
> Yes, it's entirely possible but due to the non-threadsafe nature of
> dbus-glib it isn't not really supported. Are you sure the the thread
> isn't blocking? Of course, when we switch to GDBus (which is
> threadsafe) then problems like this go away.
Okay, I already expected something like this...
> Could I ask why you're trying to run it in a thread rather than just
> in an idle callback?
This is a little bit difficult... I have written a library which makes use
of PackageKit in several ways (search for packages/files, resolve names
etc.). It also runs a lot of other stuff, which blocks the GUI application
that makes use of the lib as long as these processes run.
Some time ago I received a bug report, describing that the GUI app
completely freezes short time after the first PackageKit command was run.
It stopped at g_main_loop_run(). This behavior could only be seen with the
GTK+ GUI, the Qt4-GUI app was not affected. So I thought the library
mainloop was blocking the one in the GTK-app - I moved all processes which
made use of PackageKit to separate threads to get rid of the main loop.
Conclusion: I hadn't any "good" reason for running all in threads, except
for the whish to avoid the UI freeze. Unfortunately this did not solve the
problem but therefore the app now sometimes crashes cause I use dbus-glib
too which is - as you said - not threadsafe. I reverted the experimental
changes and wanted to know now if it makes sense to continue searching in
this direction.
Finally I found out that the mainloop was not the problem for the freeze,
as I now found out:
[packagekitd verbose output]
--------------
- adding transaction 0x1a4d090, item 0x1a31e00
TI:19:50:14 FI:pk-engine.c FN:pk_engine_get_tid,293
- sending tid: '/183_dbcdddea_data'
TI:19:50:14 FI:pk-engine.c FN:pk_engine_reset_timer,189
- reset timer
TI:19:50:14 FI:pk-transaction-db.c
FN:pk_transaction_db_defer_write_job_count_cb,528
- doing deferred write syncronous
--------------
This means the daemon got my request to resolve a file path.
(pk_client_search_files_async())
--------------
TI:19:50:14 FI:pk-transaction.c FN:pk_transaction_set_hints,4699
- SetHints method called: locale=de_DE.UTF-8, background=false,
interactive=true
TI:19:50:14 FI:pk-transaction.c FN:pk_transaction_set_hint,4678
- unknown option: interactive with value true
TI:19:50:16 FI:pk-transaction-list.c
FN:pk_transaction_list_is_consistent,734
- checking consistency as length 1
TI:19:50:16 FI:pk-transaction-list.c
FN:pk_transaction_list_print,702
- State:
0 unknown /183_dbcdddea_data running[0] committed[0] finished[0]
background[0]
--------------
Okay, working...
--------------
TI:19:50:16 FI:pk-transaction-list.c
FN:pk_transaction_list_is_consistent,763
- 1 have an unknown role (GetTid then nothing?)
TI:19:50:16 FI:pk-transaction-list.c
FN:pk_transaction_list_is_consistent,767
- 1 have not been committed and may be pending auth
TI:19:50:16 FI:pk-engine.c FN:pk_engine_get_seconds_idle,750
- engine idle zero as 1 transactions in progress
TI:19:50:16 FI:pk-main.c FN:pk_main_timeout_check_cb,139
- idle is 0
-------------
Could you please explain those lines? Why is the daemon not processing my
request or throwing an error message?
Thanks
Matthias
More information about the PackageKit
mailing list