[Twisted-Python] Deferred SOAP methods

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri Nov 13 15:46:47 EST 2009


On 03:42 pm, landreville at deadtreepages.com wrote:
>On Fri, Nov 13, 2009 at 10:25 AM, <exarkun at twistedmatrix.com> wrote:
>
>[snip]
>>
>>What is it that you're going to be doing in these SOAP methods?
>>
>>Jean-Paul
>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.
>
>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?

There are lots of ways.  Deferreds are just an approach to organizing 
callbacks.  If you're actually asking if there's a way to call blocking 
functions without blocking - no, threads are more or less it (there's 
processes too, but that's sort of the same thing).

Database access is definitely an area where you often have to deal with 
blocking APIs.  If that's why your methods block, then threads might be 
the right solution.  You might want to take a look at 
twisted.enterprise.adbapi, a thread-based wrapper for DB-API 2.0 
modules.

If you're blocking waiting for the network or other events, though, then 
you can probably find a Twisted API to deal with that without using 
threads.

Jean-Paul



More information about the Twisted-Python mailing list