Thanks for the reply.  I am using twisted conch to connect to the remote machines and start these tests, I am thinking that instead of using one connection for all testing I will open a new connection (and thus a new python) for each test.  Like I said increasing the thread pool size worked well for fast machines but no so well on older ones.  I am hoping that this behavior has more to do with the GIL and that 5 processes on a slow machine will operate better than 5 python threads.  <br>

If not, then I will just have to write some sort of system to make sure I dont open too many threads on certain remote machines.<br><br>Thanks again<br><br><div class="gmail_quote">On Fri, Mar 18, 2011 at 8:40 PM,  <span dir="ltr">&lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">On 10 Mar, 11:08 pm, <a href="mailto:charlessolar@gmail.com">charlessolar@gmail.com</a> wrote:<br>


&gt;I am using PB to run remote methods in a testing system at my company.<br>
&gt;The<br>
&gt;code works very well but breaks down when I start running multiple<br>
&gt;tests at<br>
&gt;once.  I have tracked this down to overflowing the thread pool on the<br>
&gt;remote<br>
&gt;machines.  I am wondering if anyone might have better suggestions for<br>
&gt;running long methods from a remote method.<br>
&gt;<br>
&gt;I coded up a sample of what I am seeing here:<br>
&gt;<a href="http://pastebin.com/rBPp20Ms" target="_blank">http://pastebin.com/rBPp20Ms</a><br>
&gt;<br>
&gt;Basically I have 1 server that calls remote_execute on many clients on<br>
&gt;a<br>
&gt;remote server.  This remote_execute method starts a new method using<br>
&gt;threads.deferToThread and returns the defer to make the server&#39;s<br>
&gt;callRemote<br>
&gt;defer wait until the remote long method end.<br>
&gt;What I do in those methods is run test code that waits, blocks, sleeps,<br>
&gt;and<br>
&gt;all sorts of nasty things that make the thread take a while.  In the<br>
&gt;example<br>
&gt;code I simply sleep for 20 seconds.<br>
&gt;<br>
&gt;The problem I see with this code specifically is that I run out of<br>
&gt;threads<br>
&gt;on the pool and even though I wanted all execute methods to run at the<br>
&gt;same<br>
&gt;time, I see 10 run, then 10 more, then 10 more.. etc.  The testing<br>
&gt;depends<br>
&gt;on all these methods being run at the same time as they run mechanisms<br>
&gt;that<br>
&gt;depend on each other and need everyone running.  When I overflow the<br>
&gt;thread<br>
&gt;pool some methods do not run until other methods stop, which makes the<br>
&gt;whole<br>
&gt;test fail.<br>
<br>
</div></div>This is how the thread pool works.  It has a maximum size, which limits<br>
the number of threads it will create to process work given to it.<br>
Beyond that number of concurrent tasks, things will begin to get queued<br>
up and wait for a free thread to execute them.<br>
<br>
Each task you give to the thread pool exclusively uses one of its<br>
threads for the entire duration of the task, regardless of what the task<br>
consists of.<br>
<div class="im">&gt;I am not holding the GIL or blocking the reactor, which was the first<br>
&gt;thing<br>
&gt;I checked.<br>
&gt;<br>
&gt;Setting reactor.suggestThreadPoolSize(50) does help, but I do not think<br>
&gt;its<br>
&gt;the best solution, and does not work very well on our slow and older<br>
&gt;machines.<br>
<br>
</div>Using more threads is the only solution to the problem of not using<br>
enough threads.  Alternatively, look for wards to process tasks without<br>
using threads.<br>
<br>
Jean-Paul<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">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>