<br><br><div class="gmail_quote">On Fri, Nov 13, 2009 at 3:46 PM, <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 03:42 pm, <a href="mailto:landreville@deadtreepages.com">landreville@deadtreepages.com</a> wrote:<br>
>On Fri, Nov 13, 2009 at 10:25 AM, <<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>> wrote:<br>
><br>
</div>>[snip]<br>
<div class="im">>><br>
>>What is it that you're going to be doing in these SOAP methods?<br>
>><br>
>>Jean-Paul<br>
>They are doing a bunch of setting and retrieving information from<br>
>databases.<br>
>There are a couple that load more modules which add more SOAP methods<br>
>for<br>
>interacting with a different database.<br>
><br>
>None of the calls depend on eachother, so I don't want/need any of them<br>
>to<br>
>block the application from processing the next soap call. Is there<br>
>other<br>
>ways of generating deferreds without threads that I haven't seen?<br>
<br>
</div>There are lots of ways. Deferreds are just an approach to organizing<br>
callbacks. If you're actually asking if there's a way to call blocking<br>
functions without blocking - no, threads are more or less it (there's<br>
processes too, but that's sort of the same thing).<br>
<br>
Database access is definitely an area where you often have to deal with<br>
blocking APIs. If that's why your methods block, then threads might be<br>
the right solution. You might want to take a look at<br>
twisted.enterprise.adbapi, a thread-based wrapper for DB-API 2.0<br>
modules.<br>
<br>
If you're blocking waiting for the network or other events, though, then<br>
you can probably find a Twisted API to deal with that without using<br>
threads.<br>
<div><div></div><div class="h5"><br>
Jean-Paul<br><br>
</div></div></blockquote></div><br><div>Most of the time it is datbase access. I guess I shouldn't have chosen probiscus using the greentrunk api instead of the dbapi. I haven't been pleased by the postgres drivers in python, so I'm wary to change the db api and use adbapi around it.</div>
<div><br></div><div>Sometimes the calls are blocking because it is calling another SOAP server (or possibly itself over SOAP). My SOAP calls will all be blocking because twisted.web.soap doesn't support WSDL.</div><div>
Other than db access and accessing soap calls the rest is just formatting the results. </div><div><br></div><div>I'm thinking maybe I could make an attribute of my soap method called "deferred = True|False" and then if it's True render will wrap the call to the soap method in a deferred thread, otherwise I will defer blocking statements inside the SOAP method.</div>