« Return to Thread: Examples with Stackless Python Re: InlineCallback Friendly ?

Re: Examples with Stackless Python Re: InlineCallback Friendly ?

by Andrew Francis :: Rate this Message:

Reply to Author | View in Thread

Hi Thijs:

--- Thijs Triemstra | Collab <lists@...> wrote:

> I went ahead and posted your first example on this
> page: http://pyamf.org/wiki/StacklessPythonTwisted

No problem. However give me a few days so I can write
a more substantial example - for instance the same
example but also making an additional call to say a
XML-RPC backend. This where Stackless really comes in
handy.

So you get something like

#use Christopher Armstrong's blockOn technique
def blockOn(self, deferred):
    ch = stackless.channel()
    def cb(result):
        ch.send(result)
    deferred.addBoth(cb)
    return ch.receive()


def __echo__(self, request, deferred, y):
    result = blockOn(aProxy.callRemote(....)
    deferred.callback(result)

The pure Twisted example is more complex and way more
complex if you make more than one call - the callback
chain starts to become unruly.

Cheers,
Andrew




      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

 « Return to Thread: Examples with Stackless Python Re: InlineCallback Friendly ?