Due to a bug in the pygtk thread support, the attached test program hangs.

The problem is that pygdk_block_threads assumes that an accompanying
pygdk_unblock_threads has previously been called, when in fact it hasn't.  
This can happen in situations when a thread calls a non-thread-wrapped gtk
function that emits a signal (e.g. gtk_entry_set_text()), and that signal
is connected to a python function.

On a related note, pygdk_{block,unblock}_threads should really call 
gdk_threads_{leave,enter} for sanity's sake.
-- Elliot
Humpty Dumpty was pushed.
#!/usr/bin/python2.2

import gtk
import thread
gtk.gdk.threads_init()

def thr2_2(w):
        print "thr2_2 called"

def thr2(lock, entry):
        lock.acquire()
        entry.connect('changed', thr2_2)
        lock.release()
        entry.set_text('hello')

win = gtk.Window()
vbox = gtk.VBox()
ent = gtk.Entry()
ent.set_text('hi there')
win.add(vbox)
vbox.add(gtk.Label('Test label'))
vbox.add(ent)
win.show_all()
alock = thread.allocate_lock()
alock.acquire()
thread.start_new_thread(thr2, (alock, ent))
alock.release()
gtk.mainloop()
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to