On 4/10/2009 8:26 PM, Jason Voegele wrote:
I am a relative newcomer to Python and I don't know much about the Global Interpreter Lock (GIL) in general. However, I am developing a PyQt application that makes fairly heavy use of QThread to perform multiple tasks concurrently.
Usually, Qt applications don't require many threads because many things (eg: network) can be easily done without.
I've heard some vague statements that PyQt manages the GIL automatically, but can someone give a more precise statement about how the GIL works for PyQt applications, especially when QThread is involved? Are there any gotchas that I need to look out for?
Not specifically. The presence of the GIL means that two concurrent threads executing Python code can't run at the same time. The fact that your threads have been created through QThread is immaterial. PyQt releases the GIL at the C++ boundary: this means that when one thread is executing Qt's C++ code, it's not blocking the execution of other threads.
So if you call a blocking Qt operation, other threads can still continue their execution. If PyQt weren't handling GIL the correctly, any blocking Qt operation would keep the GIL locked and thus block all other threads at the same time.
-- Giovanni Bajo Develer S.r.l. http://www.develer.com _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
