[Python-ideas] A send() built-in function to drive coroutines
Victor Stinner
victor.stinner at gmail.com
Mon Feb 23 11:49:43 CET 2015
2015-02-16 13:53 GMT+01:00 Luciano Ramalho <luciano at ramalho.org>:
> At a high level, the behavior of send() would be like this:
>
> def send(coroutine, value):
> if inspect.getgeneratorstate() == 'GEN_CREATED':
> next(coroutine)
> coroutine.send(value)
It's strange to have to sometimes run one iterations of the generator,
sometimes two iterations.
asyncio.Task is a nice wrapper on top of coroutines, you never use
coro.send() explicitly. It makes coroutines easier to use.
Victor
More information about the Python-ideas
mailing list