On Thu, 2008-09-25 at 09:16 +0100, Emmanuele Bassi wrote: > threading and python are two very different beasts, with different > interactions at different levels. python is using user-level threads in > its API, as far as I know, and this is already not entirely well > behaving with the concept of GLib thread safety. so, beware and caveat > emptor apply.
Python uses system-level threads. The wrinkle is the global interpreter lock (GIL), which means that anything manipulating python objects must be synchronized. However, bindings can (and should!) wrap any code not accessing Python objects that could potentially block (a call to an image library that does an expensive scale operation, or anything involving I/O) between Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS, which will release the GIL to other threads. I believe this should mesh fine with glib thread safety. After calling Py_BEGIN_ALLOW_THREADS you'd acquire any glib/clutter/whatever locks if necessary, then release them before calling Py_END_ALLOW_THREADS. Cheers, Jason. -- To unsubscribe send a mail to [EMAIL PROTECTED]
