[PyKDE] Re: Threading problem with PyQt4 and Macosx

Matt Newell newellm at blur.com
Mon Feb 26 20:05:43 GMT 2007


On Saturday 24 February 2007 11:58, Michael Guntsche wrote:
> On Feb 24, 2007, at 10:28, Phil Thompson wrote:
> > In the meantime you could try changing PyQt's configure.py (in
> > set_sip_flags()) so that it invokes sip with the -g flag.
>
> I did some more tests and noticed something weird I do not quite
> understand.
> I once again took my trusty test script and created two different
> versions.
>
> Version 1 (old version):
>
> self.connect(self, QtCore.SIGNAL("steip(const QString &)"),
> self.container.write)
>
> Is called in the threads run()-method.
> Same old behaviour, after adding some more threads the program hangs
> and later dies.
>
> If I try to use a QueuedConnection nothing gets printed at all. Has
> this something to to with the per thread eventloop,
> I do not understand this behaviour at all.
>
This works fine for me.  Either leaving the connection type 
blank(AutoConnection), or specifying QueuedConnection results in the exact 
same behavior.  This is with the latest sip/pyqt snapshot as of friday.

> Version 2:
>
> self.connect(s, QtCore.SIGNAL("steip(const QString &)"),
> self.write,QtCore.Qt.QueuedConnection)
>
> Is called in the main thread after creating the thread (s).
> In this case the QueuedConnection works and I see that my textEdit
> field gets filled.
> Furthermore I can create a lot more threads (over 100), can kill and
> recreate them without any problems at all.
This makes sense that it would reduce the number of deadlocks, since there's 
less code paths being executed in the threads that can cause a deadlock.

Matt




More information about the PyQt mailing list