Hi.
I am writing a pygtk-1.2 app. I have lots of interaction with GnomeCanvas and
lots of threading. For example, it is common to have a thread running which
moves, creates or destroys a widget on the canvas.
In the process of doing this I encountered a number of non-deterministic,
intermitant, severe crashes related to threading problems. Even after
extensive locking they would not go away.
1) While moving an object from a thread
GnomeUI-ERROR **: file gnome-canvas.c: line 3812
(gnome_canvas_request_redraw_uta): assertion failed: (canvas->redraw_area !=
NULL)
aborting...
2) While creating an object from a thread
Xlib: unexpected async reply (sequence 0x10b9)!
(plus various other sequence numbers)
The good news is that after some thought I came up with the following solution:
I replaced the standard gtk.mainloop() with:
while 1:
App.gtk_lock.acquire()
while gtk.events_pending() and not App.quit:
gtk.mainiteration()
App.gtk_lock.release()
if App.quit:
break
time.sleep(0.01)
As long as all threaded code uses App.gtk_lock around any access to
pygtk/gnome structures, the threading errors are prevented.
I hope this may be useful to anyone else who is trying to wrangle with threads
and pygtk/pygnome.
--andy
-----------------------
Andrew W. Schmeder
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/