So I found this gist on how to create a "thread pooling" system and my issue is: when the executed function finished in the thread the "completed" signal must be emitted from (or to) the main thread. The solution presented on the gist was to overwrite GObject.emit
function using GObject.idle_add(GObject.GObject.emit, self, *args)
which does the trick in the gist example, but misteriously does not work for me. I created a slightly modified version of his code that does what I need, except from emitting the signals correctly/at all.
class _IdleObject(GObject.GObject):
""" Override GObject.GObject to always emit signals in the main thread by
emmitting on an idle handler """
@trace
def __init__(self):
GObject.GObject.__init__(self)
@trace
def emit(self, *args):
GLib.idle_add(GObject.GObject.emit, self, *args)
In summary, the signals are either not emitted or emitted on secondary threads (when the emit function overwrite is commented out) which can't update the UI therefore don't solve my problem. Any ideas on what's going on?
My version of his gist can be found here