zz.py
import asyncio
# @asyncio.coroutine
def main():
yield from asyncio.sleep(1)
next(main())
Execute in Python 3.6.7 --> OK, no error.
Execute in Python 3.7.3 --> NOT OK, reported next:
zz.py:5: RuntimeWarning: coroutine 'sleep' was never awaited yield from asyncio.sleep(1) RuntimeWarning: Enable tracemalloc to get the object allocation traceback Traceback (most recent call last): File "zz.py", line 7, in <module> next(main()) File "zz.py", line 5, in main yield from asyncio.sleep(1) TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator
I know I could enable @asyncio.coroutine to make both work, or async/await.
But, here my question is: if I still use generator, what's the difference here for python3.6 & python3.7? I really feel chaos here.