<br><br><div class="gmail_quote">On Fri, Nov 13, 2009 at 10:25 AM, <span dir="ltr"><<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>></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>
>I am making a SOAP server and all (or at least the vast majority) will<br>
>be<br>
>returning a deferred. The whole SOAP method is encapsulated in a<br>
>deferred in<br>
>most of my cases (I havent implemented this part yet.) Then I got the<br>
>idea<br>
>that twisted.web.soap could just wrap my SOAP method (retrieved with<br>
>lookupFunction) in a deferred and return that deferred right away.<br>
><br>
>For instance I would change twisted.web.soap.render where it says d =<br>
>defer.maybeDeferred to d = threads.deferToThread<br>
<br>
</div>It sounds like you're conflating Deferreds and threads a little bit.<br>
<br>
The reason Twisted doesn'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'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'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'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'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'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't seen?</div>
<div><br></div></div>