<br><br><div class="gmail_quote">On Fri, Nov 13, 2009 at 10:25 AM,  <span dir="ltr">&lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 02:52 pm, <a href="mailto:landreville@deadtreepages.com">landreville@deadtreepages.com</a> wrote:<br>
&gt;I am making a SOAP server and all (or at least the vast majority) will<br>
&gt;be<br>
&gt;returning a deferred. The whole SOAP method is encapsulated in a<br>
&gt;deferred in<br>
&gt;most of my cases (I havent implemented this part yet.) Then I got the<br>
&gt;idea<br>
&gt;that twisted.web.soap could just wrap my SOAP method (retrieved with<br>
&gt;lookupFunction) in a deferred and return that deferred right away.<br>
&gt;<br>
&gt;For instance I would change twisted.web.soap.render  where it says d =<br>
&gt;defer.maybeDeferred to  d = threads.deferToThread<br>
<br>
</div>It sounds like you&#39;re conflating Deferreds and threads a little bit.<br>
<br>
The reason Twisted doesn&#39;t use deferToThread on any method it calls by<br>
default is that threads are a really bummer.  You have to worry about<br>
thread safety, you generally lose repeatability and determinism, your<br>
unit tests become a lot harder to write, if it&#39;s still possible to write<br>
them at all.  Then there are the performance considerations.  There are<br>
many kinds of code that CPython threads don&#39;t make any faster (and many<br>
kinds which it makes slower).<br>
<br>
On the other hand, sometimes you really do want to do your work in a<br>
thread.  That&#39;s why deferToThread exists, after all - to make your life<br>
a little bit simpler when those cases do arise. :)<br>
<br>
What is it that you&#39;re going to be doing in these SOAP methods?<br>
<br>
Jean-Paul<br><br></blockquote><div><br></div><div>They are doing a bunch of setting and retrieving information from databases. There are a couple that load more modules which add more SOAP methods for interacting with a different database.</div>
<div><br></div><div> None of the calls depend on eachother, so I don&#39;t want/need any of them to block the application from processing the next soap call. Is there other ways of generating deferreds without threads that I haven&#39;t seen?</div>
<div><br></div></div>