[Twisted-Python] Deferred SOAP methods

Landreville landreville at deadtreepages.com
Fri Nov 13 16:03:55 EST 2009

On Fri, Nov 13, 2009 at 3:46 PM, <exarkun at twistedmatrix.com> wrote:

> 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
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.

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.
Other than db access and accessing soap calls the rest is just formatting
the results.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20091113/a2bcd398/attachment-0001.htm 

More information about the Twisted-Python mailing list