Problem with queues and gobject event loop

Roman Kapl msntfs at
Fri Sep 11 21:22:00 CEST 2009

Why does not this snipplet work?
from job import JobQueue
import Queue
import threading
import gobject
def worker():
    print "Worker waiting"
    print "Got job!"

if __name__ == "__main__":
    t = threading.Thread(target=worker)
    loop = gobject.MainLoop()
It blocks indefinitely on the q.get() in the worker thread. When I
remove the the gobject main loop call, the code works fine and worker
thread gets to the print "Got job!" statement. This is just simplified
example to show the weird behaviour, otherwise I am trying to receive
messages via DBus and schedule jobs for another thread(I am a DBus
server). So is it a bug, my mistake or just simply queues can't be
used in combination with gobject main loop? Can I use dbus without
main loop(since I really don't need it, but I couldn't find any
example how to get rid of it.

Thank you.

More information about the Python-list mailing list