On Wed, Apr 22, 2015 at 9:45 PM, Yury Selivanov <yselivanov...@gmail.com> wrote:
> Andrew,
>
> On 2015-04-22 2:32 PM, Andrew Svetlov wrote:
>>
>> For now I can use mix asyncio.coroutines and `async def` functions, I
>> mean I can write `await f()` inside async def to call
>> asyncio.coroutine `f` and vise versa: I can use `yield from g()`
>> inside asyncio.coroutine to call `async def g(): ...`.
>
>
> That's another good point that I forgot to add to the list.
> Thanks for bringing this up.
>
>>
>> If we forbid to call `async def` from regualr code how asyncio should
>> work? I'd like to push `async def` everywhere in asyncio API where
>> asyncio.coroutine required.
>
>

> You'll have to use a wrapper that will do the following:
>
> async def foo():
>     return 'spam'
>
> @asyncio.coroutine
> def bar():
>     what = yield from foo.__await__(foo, *args, **kwargs)
>     # OR:
>     what = yield from await_call(foo, *args, **kwargs)
>
If I cannot directly use `yield from f()` with `async def f():` then
almost every `yield from` inside asyncio library should be wrapped in
`await_call()`. Every third-party asyncio-based library should do the
same.

Also I expect a performance degradation on `await_call()` calls.

> Thanks,
> Yury



-- 
Thanks,
Andrew Svetlov
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to