[Stackless] Stackless and Psyco

Christopher Armstrong radix at twistedmatrix.com
Mon Mar 1 21:00:13 CET 2004

Bob Ippolito wrote:

>  A fourth option, I suppose, would be to use
> yield Yet
> yield Another
> yield Style
> yield of
> yield explicitly
> yield asynchronous
> yield socket
> yield code
> but I don't there there is a good framework that supports this quite yet 
> (I've personally integrated such a beast with Twisted, and PEAK events 
> is similar, so I know this approach does work and is a bit more sane 
> than "raw" Twisted).

I assume you have checked out twisted.flow? Oh right. I remember. You 
wrote the original 'flow' module and then cce stole the name ;-) I 
recently used it to port some blocking code to Twisted and it made me as 
happy as a clam :) Of course, it's not the most concise thing, requiring 
something like:

def _myCodeThatUsedToBlock():
   thing = flow.wrap(getDeferred())
   yield thing
   thing = thing.next()

and then

def myCodeThatUsedToBlock():
   return flow.Deferred(myCodeThatUsedToBlock()
                       ).addCallback(lambda x: x[0])

But it's still incredibly useful. I've been thinking about using 
bytecode hacks to implement a 'wait()' macro. You would say something like:

def myCodeThatUsedToBlock():
  return wait(getDeferred())


And it would search the current module for functions that call 'wait', 
convert the 'wait' calls to the previous 'yield' dance, and 
automatically wrap them with functions that call flow.Deferred on their 
result... :-D

Hmm, sorry for being off-topic.

  Twisted | Christopher Armstrong: International Man of Twistery
   Radix  |          Release Manager,  Twisted Project
---------+           http://radix.twistedmatrix.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://www.stackless.com/pipermail/stackless/attachments/20040301/5a6f130d/attachment.pgp>
-------------- next part --------------
Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list