Elliot Lee wrote:

On Wed, 25 Jun 2003, Elliot Lee wrote:



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.



The attached patch seems to fix this particular problem.




On a related note, pygdk_{block,unblock}_threads should really call gdk_threads_{leave,enter} for sanity's sake.



This still is an issue - I can't just put the calls into pygdk_{block,unblock}_threads.


Thanks for looking into this. To be honest, I haven't really put that much work into the threading support in pygtk HEAD. Most of the work has been in the form of patches from people actually writing threaded pygtk programs.

Eventually I want to see if it is possible to rip out half of the threading hacks in pygtk and make use of the new PyGILState_Ensure() and PyGILState_Release() functions that are in Python 2.3. These essentially turn the global interpreter lock into a recursive lock. Since these calls are at the Python level, a lot of the hacks disapear and pygtk should work better with unrelated modules that happen to be thread aware. This changes the wrapper for most callbacks to:
PyGILState_STATE state = PyGILState_Ensure();
/* do stuff */
PyGILState_Release(state);


Things like the gtk_main() wrapper can change to use the standard Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair.

Of course, I want to keep Python 2.2 compat for pygtk-2.0, so the PyGILState changes will have to happen after branching.

For 2.0, it is probably a good idea to apply your patch, since it seems to fix some problems and looks basically correct. It would be good to hear what some other people think about the patch though (some of the Ximian guys in particular, who have done some work with the threading code recently).

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
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