Event loop management with Asyncio

The Python module Asyncio provides facilities to manage events, coroutines, tasks and threads, and synchronization primitives to write concurrent code. The main components and concepts of this module are:

  • An event loop: The Asyncio module allows a single event loop per process
  • Coroutines: This is the generalization of the subroutine concept. Also, a coroutine can be suspended during the execution so that it waits for external processing (some routine in I/O) and returns from the point at which it had stopped when the external processing was done.
  • Futures: This defines the Future object, such as the concurrent.futures module that represents a computation that has still not been accomplished.
  • Tasks: This is a subclass ...

Get Python Parallel Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.