1:mod:`asyncio` --- Asynchronous I/O, event loop, coroutines and tasks 2===================================================================== 3 4.. module:: asyncio 5 :synopsis: Asynchronous I/O, event loop, coroutines and tasks. 6 7.. versionadded:: 3.4 8 9**Source code:** :source:`Lib/asyncio/` 10 11-------------- 12 13This module provides infrastructure for writing single-threaded concurrent 14code using coroutines, multiplexing I/O access over sockets and other 15resources, running network clients and servers, and other related primitives. 16Here is a more detailed list of the package contents: 17 18* a pluggable :ref:`event loop <asyncio-event-loop>` with various system-specific 19 implementations; 20 21* :ref:`transport <asyncio-transport>` and :ref:`protocol <asyncio-protocol>` abstractions 22 (similar to those in `Twisted <https://twistedmatrix.com/trac/>`_); 23 24* concrete support for TCP, UDP, SSL, subprocess pipes, delayed calls, and 25 others (some may be system-dependent); 26 27* a :class:`Future` class that mimics the one in the :mod:`concurrent.futures` 28 module, but adapted for use with the event loop; 29 30* coroutines and tasks based on ``yield from`` (:PEP:`380`), to help write 31 concurrent code in a sequential fashion; 32 33* cancellation support for :class:`Future`\s and coroutines; 34 35* :ref:`synchronization primitives <asyncio-sync>` for use between coroutines in 36 a single thread, mimicking those in the :mod:`threading` module; 37 38* an interface for passing work off to a threadpool, for times when 39 you absolutely, positively have to use a library that makes blocking 40 I/O calls. 41 42Asynchronous programming is more complex than classical "sequential" 43programming: see the :ref:`Develop with asyncio <asyncio-dev>` page which lists 44common traps and explains how to avoid them. :ref:`Enable the debug mode 45<asyncio-debug-mode>` during development to detect common issues. 46 47Table of contents: 48 49.. toctree:: 50 :maxdepth: 3 51 52 asyncio-eventloop.rst 53 asyncio-eventloops.rst 54 asyncio-task.rst 55 asyncio-protocol.rst 56 asyncio-stream.rst 57 asyncio-subprocess.rst 58 asyncio-sync.rst 59 asyncio-queue.rst 60 asyncio-dev.rst 61 62.. seealso:: 63 64 The :mod:`asyncio` module was designed in :PEP:`3156`. For a 65 motivational primer on transports and protocols, see :PEP:`3153`. 66 67