python - What is the difference between @types.coroutine and @asyncio.coroutine decorators? -
documentations say:
@asyncio.coroutine
decorator mark generator-based coroutines. enables generator use yield call async def coroutines, , enables generator called async def coroutines, instance using await expression.
_
@types.coroutine(gen_func)
this function transforms generator function coroutine function returns generator-based coroutine. generator-based coroutine still generator iterator, considered coroutine object , awaitable. however, may not implement
__await__()
method.
so seems purposes same - flag generator coroutine (what async def
in python3.5 , higher features).
when need use asyncio.coroutine
when need use types.coroutine
, diffrence?
Comments
Post a Comment