[Python-ideas] An async facade? (was Re: [Python-Dev] Socket timeout and completion based sockets)

Guido van Rossum guido at python.org
Fri Nov 30 23:55:33 CET 2012


On Fri, Nov 30, 2012 at 2:37 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Guido van Rossum wrote:
>>
>> Futures or callbacks, that's the question...
>>
>> Richard and I have even been considering APIs like this:
>>
>> res = obj.some_call(<args>)
>> if isinstance(res, Future):
>>     res = yield res
>
>
> I thought you had decided against the idea of yielding
> futures?

As a user-facing API style, yes. But this is meant for an internal API
-- the equivalent of your bare 'yield'. If you want to, I can consider
another style as well


res = obj.some_call(<args>)
if isinstance(res, Future):
    res.<magic_call>()
    yield

But I don't see a fundamental advantage to this.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list