[PyKDE] Threads & PyQt 3?

Gerard Vermeulen gvermeul at polycnrs-gre.fr
Fri Feb 22 13:05:20 GMT 2002


I am also interested in multithreading for a PyQt  based
mulitmedia application. Presently, I have mostly worked
on low level stuff and did not think very carefull about this
problem. However, my current understanding is the following:

(1) it is possible to use the Python threads in combination with PyQt.

(2) if PyQt wrapped C++ function calls take a lot of CPU time they won't
let other threads run in parallel. For that to happen, one should place
the macros Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS
around the C++ function calls. (see for instance the source code of pygame
at www.pygame.org how to use  those macros). For me this will be most
useful. If need arises I WILL try to patch sip to produce code for those
macros, allthoug I am certainly not the most qualified person :-).
I guess that tor this to work, qwtcmodule should be linked to a multithreaded
version of Qt.

(3) making Qt's thread related stuff available at the PyQt level. Qt's
threading mechanism is rather similar to Python's threading mechanism.
I think that it is most usefull for programmers who want to use their C++
threaded classes from PyQt. If not, it is maybe better to stick to Python's
mechanism

(4) make your own multi-threaded Python types (like the MPEG player
in pygame). This allows you to use all features of for instance
the pthread library instead of basing your choice of features on a lowest 
common denominator (Python threading or Qt threading).

Gerard

On Wednesday 20 February 2002 01:33, Phil Thompson wrote:
> "John J. Lee" wrote:
> > Does threading work at all / well in PyQt 3?  Any examples if so?
>
> I've not added the thread related stuff. However, with the new
> versioning system (put in for Qt/Embedded) I think it should now be
> fairly easy to do.
>
> Phil
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde





More information about the PyQt mailing list