[Python-Dev] async/await in Python; v2 (original) (raw)
Andrew Svetlov andrew.svetlov at gmail.com
Wed Apr 22 20:53:09 CEST 2015
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Apr 22, 2015 at 9:45 PM, Yury Selivanov <yselivanov.ml at 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 writeawait f()
inside async def to call asyncio.coroutinef
and vise versa: I can useyield from g()
inside asyncio.coroutine to callasync 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 pushasync 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 awaitcall(foo, *args, **kwargs) If I cannot directly use
yield from f()
withasync def f():
then almost everyyield from
inside asyncio library should be wrapped inawait_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
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]