I'm learning Python, more specially parallel programming using Python Parallel Programming Cookbook by Giancarlo Zaccone.

At the time the book was published async/await was still in the beta version of Python, and so, the book doesn't cover it. It covers Asyncio. Now with the release of Python 3.5, async/await has been implemented in Python.

What are the differences between Asyncio.wait() and async/await? Is it just a syntax difference?

  • @RobertHarvey is asyncio.wait the same as using async and wait? – user204828 Nov 20 '15 at 15:34
  • 2
    On your deleted question on Stack Overflow, someone commented: "async/await does not replace the asyncio module; nearly everything the book will teach you is still relevant for 3.5, only some details of syntax have changed." – Robert Harvey Nov 20 '15 at 15:35
  • 2
    I've cleaned up this question to make it appropriate for Programmers. I think that we can address the conceptual differences, if any, between these two approaches. It appears to be a well-written and on-topic question for us in its current form. – Thomas Owens Nov 20 '15 at 16:09

See this excellent blog post. In brief, asyncio is an event loop library (introduced in 3.4) that's focused on I/O, and largely on networking in particular. It introduced the asyncio.coroutine decorator to let you identify generators meant to be used as coroutines. In any generator, you can yield from any other generator (or coroutine).

In 3.5 the keywords async and await were introduced. You can only await inside an async function, and you can only await on a coroutine or Awaitable. You cannot await a general generator, and you cannot use yield or yield from. This helps protect against accidentally using a generator as a coroutine.

async and await are general enough to be used with any event loop provider, and asyncio happens to be one.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.