[Twisted-Python] How to return a meaningful response to an AMP command when deferreds are involved?

Nathan nathan.stocks at gmail.com
Wed Apr 2 13:24:45 MDT 2008


On Wed, Apr 2, 2008 at 1:10 PM, Jean-Paul Calderone <exarkun at divmod.com> wrote:
> On Wed, 2 Apr 2008 13:05:49 -0600, Nathan <nathan.stocks at gmail.com> wrote:
>
> > On my AMP server I'm using twisted.enterprise to query a postgres
> > database and do inserts.  I'd like to return whether the insert
> > succeeded or failed as the response to the AMP responder function --
> > is there an established pattern for doing things like that?
> >
>
>  If a responder returns a Deferred, then the result of the Deferred is
>  taken as the response to the request.

Aha!  Things are falling into place.  I've run into this problems
several times, and that's the piece that I had missed.  Thanks a
million!

/me needs to go read the docs on deferreds for a fourth time...

~ Nathan




More information about the Twisted-Python mailing list