I am writing a python software using gtk in combination with threads. Now there is a part where I have to use something like gobject.idle_add(function)
.
My problem is, that the part after that call should really be executed after the function i passed to idle_add is finished.
do_some_things_before()
gobject.idle_add(do_something)
do_some_things_after()
My question is: Will gobject.idle_add(do_something)
block until do_something()
is finished executing?
Thanks, patsimm
No.
idle_add()
merely queues your function to be run the next time no events are pending. You will need to add some synchronization code.Furthermore, if the callback function returns the GLib constant
TRUE
(not sure what the PyGTK+ equivalent is) the function will be requeued for the next idle point, so there's no point in waiting for a function that could potentially never really be finished. (ReturnFALSE
to remove the function from the queue.)I don't see a reference to the C equivalent
gdk_threads_idle_add()
in the PyGTK+ reference; I'm going to assume the one you're calling will also run the function on the GUI thread.