Hello. I'm implementing a pygtk front-end to an extension module that wraps a library and I'm having problems.
It goes something like this: The gui creates a thread to run a lengthy and I/O based call. The call is made to the extension module and callbacks are invoked, through some callback wrappers that will call pygtk code, but are meant to be generic and supplyable by the front end. What happens now is this. When the call runs in the thread, the front end sits there waiting for a threading.Event to be set, and does while gtk.events_pending(): gtk.main_iteration(). So the call goes fine, I can set_fraction a progress bar, but when the call to the library performs a C system("ldconfig -r /"), the ui freezes, or more generally when some heavy I/O is involved. What I do now is, call gtk.threads_init() before the ui starts, then in the extension module, and before PyObject_Call, I save the current thread state with PyEval_SaveThread, and then after it runs I perform a PyEval_RestoreThread, this on the extension module calls that will be run in a thread. On the callback wrappers, and after a segfault in PyFrame_new or something like that, I've figured out that I need to restore the thread state again. So if anyone would be so kind to explain to me some things about the GIL and gtk threads and help me a little bit with this, I'd be very thankful. I've been running hitting my head against the walls for some time with this. Joao. -- A mind all logic is like a knife all blade. It makes the hand bleed that uses it. -- Rabindranath Tagore (1861-1941) _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/