[Python-ideas] The async API of the future: Twisted and Deferreds

Richard Oudkerk shibturn at gmail.com
Sat Oct 13 11:30:16 CEST 2012


On 13/10/2012 1:22am, Guido van Rossum wrote:
> I don't think it follows that there can only be one reactor if they
> are registered immediately. There could be a notion of "current
> reactor" maintained in thread-local context; moreover it could depend
> on the reactor that made the callback that caused the current task to
> run. The reactor could also be chosen by the code that made the
> Future. (Though I'm not immediately sure how that would work in the
> yield-from scenario -- but I'm sure there's a way.)

Alternatively, yielding a future (or whatever ones calls the objects 
returned by *_async()) could register *and* wait for the result.  To 
register without waiting one would yield a wrapper for the future.  So 
one could write

     result = yield foo_async(...)

or

     f = yield Register(foo_async())
     # do some other work
     result = yield f


Richard




More information about the Python-ideas mailing list