Finally I managed to solve myself this obscure bug. I put the reactor.iterate() call before spawning new callbacks, in this way I force the mainloop to complete the cycle. The pseudocode would be modified in this way:<br><br>
Client()<br>    proceed_sending():<br><br>          chunk_tot = 
CHUNK_TOT<br>          chunk_no = 0<br><br>          def send(_)<br>               
 if chunk_no == CHUNK_TOT: return<br>                else:<br>                    
 ... read data...<br>                    reactor.iterate()     &lt;---------------------------------------------------------- THIS LINE<br>
                    d = filesender.callRemote(&quot;send_<div id=":ua" class="ii gt">chunk&quot;, secret,
 chunk_no, data)<br>                    d.addCallback(send)<br></div><br><br><br><div class="gmail_quote">2010/5/23 Gabriele Lanaro <span dir="ltr">&lt;<a href="mailto:gabriele.lanaro@gmail.com">gabriele.lanaro@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">After putting some strategical sleeps seems that the problem is that the application is the server and the client at once, I think that this generates a &quot;loop&quot; in the mainloop.<br>
<br><div class="gmail_quote">2010/5/23 Gabriele Lanaro <span dir="ltr">&lt;<a href="mailto:gabriele.lanaro@gmail.com" target="_blank">gabriele.lanaro@gmail.com</a>&gt;</span><div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Thank you very much for your responses, the problem seems to appear when in my tests I send the file &quot;to myself&quot;, when I send files over the network, the things goes well.  I suspect (it&#39;s just a suspect) that the code spawns too much deferreds too much fast, causing the loop not to complete (or something like that).<br>


<br>Anyway I think I&#39;ll follow your suggestion and I&#39;ll end splitting up the upload service and the control/authorization one, since the code can grow up too complex and performance is a requirement.<br><br>- Gabriele<br>


<br><div class="gmail_quote">2010/5/23 David Bolen <span dir="ltr">&lt;<a href="http://db3l.net" target="_blank">db3l.net</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt;</span><div><div></div><div>
<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div>Gabriele Lanaro &lt;<a href="mailto:gabriele.lanaro@gmail.com" target="_blank">gabriele.lanaro@gmail.com</a>&gt; writes:<br>
<br>
&gt; The problem of this approach is that this blocks my GUI, I can&#39;t figure out<br>
&gt; why because I&#39;m just generating deffereds so it souldn&#39;t block.<br>
<br>
</div>Just using deferreds won&#39;t help unless you still manage to return<br>
control back up the chain to the main event loop.  I suspect something<br>
must be blocking somewhere, though hard to say from the pseudo-code.<br>
Most likely a few judiciously placed logging statements would let you<br>
see where, or at least verify that you are not returning to the main<br>
event loop during the transfer.<br>
<br>
I will say that chunking up a large transfer through individual PB<br>
requests adds a bit of overhead for a large stream, and unless you<br>
implement some sort of windowing protocol, can hurt performance due to<br>
the latency needed to wait for the ACK from the server for each chunk.<br>
<br>
I had what appears to be a similar requirement in terms of<br>
transmitting a large file (A/V files to be published) as part of an<br>
overall PB session, and decided to separate it out to its own file<br>
upload server component coordinated through the PB session.<br>
<br>
<a href="http://twistedmatrix.com/pipermail/twisted-python/2007-July/015738.html" target="_blank">http://twistedmatrix.com/pipermail/twisted-python/2007-July/015738.html</a><br>
has some further details on what I ended up doing.  Perhaps an approach<br>
along these lines would work for you as well.<br>
<font color="#888888"><br>
-- David<br>
</font><div><div></div><div><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>
</div></div></blockquote></div></div></div><br>
</blockquote></div></div></div><br>
</blockquote></div><br>