[PyQt] Multi-tasking and GIL

Attila Csipa pyqt at csipa.in.rs
Tue Aug 4 11:03:18 BST 2009


On Tuesday 04 August 2009 11:45:49 NARCISO, Rui wrote:
> If i understood it correctly, the GIL will prevent me from multi-threading
> this heavy tasks in order to make them run in parallel.
>
> My question is then, how to do this? Will QProcess be the solution? (the
> heavy tasks can either be ran by direct python acess through a run()
> function or in stand-alone when launched from the command line)

Depends on the type of tasks you want to spread across cores. If the tasks 
themselves are not really Qt oriented, an alternative is using the 
multiprocess module (see 
http://docs.python.org/library/multiprocessing.html). If you make heavy use 
of Qt functionality in the different threads, then it sounds more like 
QProcess. Both approaches have their (dis)advantages, and, of course, 
threaded code can be quite a pain to debug :)



More information about the PyQt mailing list