There's more...

Before Python 3.5 was released, the asyncio module used generators to mimic asynchronous calls and, therefore, had a different syntax than the current version of Python 3.5.

Python 3.5 introduced the async and await keywords. Notice the lack of parentheses around the await func() call.

The following is an example of "Hello, world!", using asyncio with the new syntax introduced by Python 3.5+:

import asyncio

async def main():
print(await func())

async def func():
# Do time intensive stuff...
return "Hello, world!"

if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.0.240