Thank you very much for you answer. Maybe the twisted details removed my focus from the &quot;big picture&quot;. <br>I have one followup question, added next to its context below.. <br><br><div class="gmail_quote">On Fri, Feb 6, 2009 at 8:29 PM, Jean-Paul Calderone <span dir="ltr">&lt;<a href="mailto:exarkun@divmod.com">exarkun@divmod.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Fri, 6 Feb 2009 17:30:19 +0100, &quot;B. B.&quot; &lt;<a href="mailto:thebbzoo@gmail.com" target="_blank">thebbzoo@gmail.com</a>&gt; wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello, I am relative new to twisted, though I have manage to make a simple<br>
client server solution ( using perspective broker ) that I am now try to<br>
refactor a little.<br>
<br>
The solution is now something like :<br>
<br>
Using perspective broker, clients connects to the server ( setting up a<br>
remote reference to each other ).<br>
Via a PB call, each client can request the server do some processing. The<br>
result of &nbsp;the processing is distributed to each connected client - and the<br>
client asking for the request gets a simple status report!<br>
<br>
This solution works quite well, the only bottleneck is that all the<br>
&quot;thread-safe&quot; processing on the server is done in the mainloop of the server<br>
reactor. I want to do concurrent processing on the server!<br>
</blockquote>
<br></div>
That requires that your server be capable of doing the processing<br>
concurrently. &nbsp;If the processing is CPU bound, then you need multiple<br>
CPUs. &nbsp;If it is disk I/O bound, you need multiple disks. &nbsp;etc.</blockquote><div><br>Actually I use a quadcore processor and there is only a litte diskusage. But thanks to your reply, I am thinking on the famous &quot;Global Interpreter Lock&quot; in python. <br>
Since allmost all processing is happing in pure python, does&#39;nt the GIL prevent me to obtain any remarkable performance gain by doing concurrent processing in pure python???<br>( At least as long as I only use one process for the threads )&nbsp; <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The function doing the processing on the server, also distribute the result<br>
to all the connected clients, and returns the result to the klient asking<br>
for the request.<br>
<br>
My question is :<br>
If I just &quot;defer&quot; that function &quot;toThread&quot; ( like &nbsp;threads.deferToThread(<br>
myServerProcessingFunction ) ). Do I have potential problems, when several<br>
threads try to distribute its result to the connecting clients???<br>
</blockquote>
<br></div>
If you use deferToThread with your &quot;processing&quot; function, then the function<br>
must be thread-safe. &nbsp;Since nearly no Twisted APIs are thread-safe, it cannot<br>
use them directly. &nbsp;It may only use reactor.callFromThread to send events<br>
back to the reactor thread. &nbsp;So, in general, yes, the potential for problems<br>
exists.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
If I have a problem:<br>
Can I make a quick fix as follows: &nbsp;Within each thread ( started with the<br>
threads.deferToThread function ), I do the distributing to the clients by<br>
using the &quot;reactor.callFromThread&quot;<br>
( like reactor.callFromThread( distributeToAllClient , myResult ) where the<br>
function distributeToAllClient are using the remoteReference for each client<br>
to send the &quot;myResult&quot; )<br>
</blockquote>
<br></div>
This may work.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Or is the only solution, to let the myServerProcessingFunction returns the<br>
&quot;myResult&quot; to be distributed to all connected clients, and do the<br>
distribution in the reactor mainthread???<br>
</blockquote>
<br></div>
There are always lots of possible solutions. &nbsp;Since you are particularly<br>
interested in performance, it will probably be necessary for you to create<br>
a way to measure how well your application is performing and then repeat<br>
these measurements using different implementation techniques. &nbsp;That is the<br>
only way you&#39;ll know which one is best.<br>
<br>
Jean-Paul<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br>