Jason Heeris wrote: > Hi, > > I've been reading some conflicting advice on PyGTK and threading > recently, probably because the API went through some fairly rapid > changes recently. > > I'm a bit confused about the following points (consider them in > context of PyGTK/PyGObject unstable, ie. 2.17/2.21 respectively): > > 1. If I want to do async activity in a new Python thread spawned > from the main loop, I need to have called glib.threads_init() *before* > starting the main loop, right? But what about gtk.gdk.threads_init()? > 2. Any GTK interaction, such as emitting a signal from this new > thread, must be either: > a. done via glib.idle_add (if I'm happy to let GTK do it > whenever it next feels like it), -OR- > b. wrapped in gtk.gdk.threads_enter()/...leave(), -OR- > c. in a "with: gtk.gdk.lock:" block (equivalent to 2.b) > 3. I don't need to do the threads_enter/leave (or use the context > manager) if I only use glib.idle_add (or timeout_add, etc)
Or you could drop threads entirely, and do your async activities using the Twisted framework, designed for making asynchronous programs (where GTK event handling is just one of the asynchronous sources). Albert _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/