[PyQt] PyQt and gevent

Matias Guijarro matias.guijarro at free.fr
Sat Sep 28 10:08:48 BST 2013


Hi all,

I am using gevent within PyQt4 applications and I am looking after the 
best way to
integrate gevent and Qt.

I used to start a QTimer to run the gevent loop for a short period of 
time every 10
milliseconds, interleaving Qt and gevent event loops in time ; it's a 
very simple approach,
however it is not very efficient.

I tried other techniques like having 2 threads (one for each loop), or 
running processEvents()
in a greenlet, but I was not happy with it - in particular, when calling 
processEvents() in a
greenlet, it doesn't play well with modal dialog boxes for example and I 
also experienced
seg faults...

Finally I decided to try to have a "PyQt backend" for gevent, ie. an 
implementation of the
gevent loop using Qt constructs (QTimer, QSocketNotifier, etc.). I 
didn't find any existing code
so I created a new project yesterday, here is the link to the github page:
https://github.com/mguijarr/qtgevent

I am happy to share it with you, hopefully it can be useful to someone else.

It seems to work for the basic tests I did - but it is far from being 
complete at the moment.
Any help would be appreciated to make it better :)

Cheers,
Matias.












More information about the PyQt mailing list