Hi,<br>That is a bit odd. Are you using the latest version of SIP and PyQt?.&nbsp; When I&#39;m running the example I posted to you without the Qt.QueuedConnection parameter i get the following output:<br><br>0 starting<br>0 Creating thread
<br>3 finished in b()<br>3 finished in __main__ <br><br>The worker thread is locking the GUI thread. When I use the Qt.QueuedConnection parameter in the connect call i get the following ouput:<br><br>0 starting<br>0 Creating thread
<br>0 finished in __main__<br>3 finished in b()<br><br>As you can see the worker thread is not blocking the GUI thread.<br><br>Regards,<br>Ole<br><br><br><br><div><span class="gmail_quote">On 1/8/07, <b class="gmail_sendername">
Paul Giannaros</b> &lt;<a href="mailto:ceruleanblaze@gmail.com">ceruleanblaze@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
No such luck. I think I mentioned in the source code I tried that. See the<br>given example:<br><br>from PyQt4.QtGui import *<br>from PyQt4.QtCore import *<br><br>import sys<br>from time import time<br><br>class B (QThread):
<br>&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QThread.__init__(self)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p(&quot;Creating thread&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;def bfunc(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.sleep(3)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p(&quot;finished in b()&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;def run(self):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.exec_()<br><br><br>class A(QDialog):<br>&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QDialog.__init__(self, None)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.l = QLabel(&quot;Foo bar baz&quot;, self)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#layout = QVBoxLayout(self)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#layout.addWidget(self.l)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#self.l.move(0, 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.resize(200, 100)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.move(100, 100)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.b = b = B()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.start()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QObject.connect(self, SIGNAL(&quot;asignal&quot;), 
b.bfunc, Qt.QueuedConnection)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QTimer.singleShot(1000, self.afunc)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;def afunc (self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.emit(SIGNAL(&quot;asignal&quot;))<br><br><br>def p(msg):<br>&nbsp;&nbsp;&nbsp;&nbsp;print int(time() - start), msg<br><br>
if __name__ == &quot;__main__&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;start = time()<br>&nbsp;&nbsp;&nbsp;&nbsp;p(&quot;starting&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;app = QApplication(sys.argv)<br>&nbsp;&nbsp;&nbsp;&nbsp;a = A()<br>&nbsp;&nbsp;&nbsp;&nbsp;a.show()<br>&nbsp;&nbsp;&nbsp;&nbsp;#a.afunc()<br>&nbsp;&nbsp;&nbsp;&nbsp;p(&quot;finished in __main__&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;sys.exit(app.exec_())<br><br><br><br>I have discovered, however, that regular Python threads work fine if I use a<br>data-based/mutex model. I think i&#39;ll go with that for now.<br><br><br>On Monday 08 January 2007 13:25, Ole Morten Grodås wrote:
<br>&gt; Hi,<br>&gt;<br>&gt; Try using Qt.QueuedConnection. I think that is your problem. Her is an<br>&gt; example:<br>&gt;<br>&gt; import sys<br>&gt; from time import time<br>&gt; from PyQt4.QtCore import *<br>&gt;<br>&gt; class B (QThread):
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; def __init__(self):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QThread.__init__(self)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(&quot;Creating thread&quot;)<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; def bfunc(self):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.sleep(3)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(&quot;finished in b()&quot;)
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; def run(self):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.exec_()<br>&gt;<br>&gt; class A (QObject):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; def __init__(self):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QObject.__init__(self)<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; def afunc (self):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.emit(SIGNAL(&quot;asignal&quot;))<br>&gt;<br>&gt;<br>&gt; def p(msg): print int(time()-start),msg<br>&gt; if __name__==&quot;__main__&quot;:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; start=time()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; p(&quot;starting&quot;)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; app=QCoreApplication(
sys.argv)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; a=A()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; b=B()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; b.start()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; QObject.connect(a,SIGNAL(&quot;asignal&quot;),b.bfunc,Qt.QueuedConnection)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; a.afunc()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; p(&quot;finished in __main__&quot;)
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; sys.exit(app.exec_())<br>&gt;<br>&gt;<br>&gt; The example gives this output<br>&gt; 0 starting<br>&gt; 0 Creating thread<br>&gt; 0 finished in __main__<br>&gt; 3 finished in b()<br>&gt;<br>&gt;<br>&gt;
<br>&gt; Regards,<br>&gt; Ole Morten Grodås<br>&gt;<br>&gt; On 1/7/07, Paul Giannaros &lt;<a href="mailto:ceruleanblaze@gmail.com">ceruleanblaze@gmail.com</a>&gt; wrote:<br>&gt; &gt; I&#39;ve been trying to get the main GUI thread to pass a URL to a worker
<br>&gt; &gt; thread<br>&gt; &gt; and have it download that (without the GUI thread blocking). I haven&#39;t<br>&gt; &gt; been<br>&gt; &gt; able to do it successfully, i&#39;ve tried all manner of connects/postEvents.<br>
&gt; &gt; Here is a simplified example:<br>&gt; &gt;<br>&gt; &gt; <a href="http://rafb.net/p/etOoSH97.html">http://rafb.net/p/etOoSH97.html</a><br>&gt; &gt;<br>&gt; &gt; In the example i&#39;m trying to get the main thread to cause the MyThread
<br>&gt; &gt; instance to sleep without blocking the main thread. In MyThread.run I<br>&gt; &gt; call MyThread.foo (which blocks for 5 seconds) without a problem - the<br>&gt; &gt; GUI thread<br>&gt; &gt; isn&#39;t being blocked. When I try to get the main thread to indirectly
<br>&gt; &gt; invoke<br>&gt; &gt; foo (via emitting a signal that the thread listens for, or by posting an<br>&gt; &gt; event that MyThread picks up in customEvent), then the GUI thread blocks.<br>&gt; &gt;<br>&gt; &gt; It&#39;s quite crippling. What&#39;s the correct way to go about this?
<br>&gt; &gt;<br>&gt; &gt; Thanks,<br>&gt; &gt; Paul<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; PyKDE mailing list&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:PyKDE@mats.imk.fraunhofer.de">PyKDE@mats.imk.fraunhofer.de
</a><br>&gt; &gt; <a href="http://mats.imk.fraunhofer.de/mailman/listinfo/pykde">http://mats.imk.fraunhofer.de/mailman/listinfo/pykde</a><br><br>_______________________________________________<br>PyKDE mailing list&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:PyKDE@mats.imk.fraunhofer.de">
PyKDE@mats.imk.fraunhofer.de</a><br><a href="http://mats.imk.fraunhofer.de/mailman/listinfo/pykde">http://mats.imk.fraunhofer.de/mailman/listinfo/pykde</a><br></blockquote></div><br>