When I go to the asyncio
page, the first example is a hello world program. When I run it on python 3.73
, I can't see any different from the normal one, can anyone tell me the difference and give a non-trivial example?
In [1]: import asyncio
...:
...: async def main():
...: print('Hello ...')
...: await asyncio.sleep(5)
...: print('... World!')
...:
...: # Python 3.7+
...: asyncio.run(main())
Hello ...
... World!
In [2]:
In [2]: import time
...:
...: def main():
...: print('Hello ...')
...: time.sleep(5)
...: print('... World!')
...:
...: # Python 3.7+
...: main()
Hello ...
... World!
I intentionally increase the time from 1s to 5s, hope to see something special but I didn't.