global interpreter lock

Stephen Thorne stephen.thorne at gmail.com
Wed Sep 14 22:46:32 EDT 2005


On 15/09/05, Michael Sparks <ms at cerenity.org> wrote:
> At the moment, one option that springs to mind is this:
>     yield WaitDataAvailable("inbox")

Twisted supports this.

help("twisted.internet.defer.waitForDeferred")

example usage is:

@deferredGenerator
def thingummy():
  thing = waitForDeferred(makeSomeRequestResultingInDeferred())
  yield thing
  thing = thing.getResult()
  print thing #the result! hoorj!

With the new generator syntax, it becomes somewhat less clunky,
allowing for the syntax:

@defgen
def foo():
   somereturnvalue = yield SomeLongRunningOperation()
   print somereturnvalue

http://svn.twistedmatrix.com/cvs/sandbox/radix/newdefgen.py?view=markup&rev=14348

-- 
Stephen Thorne
Development Engineer



More information about the Python-list mailing list