O'Reilly logo

Software Architecture with Python by Anand Balachandran Pillai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The asyncio module in Python

The asyncio module in Python provides support for writing concurrent, single-threaded programs using co-routines. It is available only in Python 3.

A co-routine using the asyncio module is one that uses either of the following approaches:

  • Using the async def statement for defining functions
  • Being decorated using the @asyncio.coroutine expression

Generator-based co-routines use the second technique, and they yield from expressions.

Co-routines created using the first technique typically use the await <future> expression to wait for the future to be completed.

Co-routines are scheduled for execution using an event loop, which connects the objects and schedules them as tasks. Different types of event loop are provided for different ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required