[PyQt] Aplication frozen when waiting response from connections

David Boddie david at boddie.org.uk
Thu Jun 21 23:59:17 BST 2007


On Mon, 18 Jun 2007 22:50:31 -0300, Reinaldo Carvalho wrote:

> I working in a program to manage cyrus and ldap accounts using pytq,
> and this program as frozen when wait for response of ldap searchs or
> listing cyrus mailboxes on bigger databases, and go back normal when
> received responses. I think this is normal beacause i insert actions
> directly when pushbutton as clicked.

Yes, there's only one thread, and any blocking operation will cause
the rest of the application to wait until it is finished.

> I think that starting a function as a thread the main window dont
> fronzen when waiting for resonses os servers connections. But i dont
> know do this.

If you are using Twisted for your networking code, there may be a way to
do this without threads since there is apparently a way to mix Twisted's
event model with the one used by PyQt, though maybe this only works
with non-blocking operations.

If you can use non-blocking network communication, you could even just run
PyQt's event loop periodically yourself by calling qApp.processEvents().

There are three threading examples in the PyQt4 distribution that have been
ported from C++ (look in the examples/threads directory). You might want to
take a look at them to get an idea of what you can do with threads.

David


More information about the PyQt mailing list