blob: 23731b13212091930f41dd7b627c17d7e30fb0ee [file] [log] [blame]
Guido van Rossum7a465642013-11-22 11:47:22 -08001: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
Guido van Rossumf8d0ff92013-11-22 16:53:25 -08009**Source code:** :source:`Lib/asyncio/`
10
11--------------
Guido van Rossum7a465642013-11-22 11:47:22 -080012
Antoine Pitroubba86822013-11-23 00:34:26 +010013This 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.
Antoine Pitroubba86822013-11-23 00:34:26 +010016Here is a more detailed list of the package contents:
17
Victor Stinner9592edb2014-02-02 15:03:02 +010018* a pluggable :ref:`event loop <asyncio-event-loop>` with various system-specific
Antoine Pitroubba86822013-11-23 00:34:26 +010019 implementations;
20
Victor Stinner9592edb2014-02-02 15:03:02 +010021* :ref:`transport <asyncio-transport>` and :ref:`protocol <asyncio-protocol>` abstractions
Antoine Pitroubba86822013-11-23 00:34:26 +010022 (similar to those in `Twisted <http://twistedmatrix.com/>`_);
23
24* concrete support for TCP, UDP, SSL, subprocess pipes, delayed calls, and
25 others (some may be system-dependent);
26
Brian Curtina1afeec2014-02-08 18:36:14 -060027* a :class:`Future` class that mimics the one in the :mod:`concurrent.futures`
Victor Stinner99c2ab42013-12-03 19:17:25 +010028 module, but adapted for use with the event loop;
Antoine Pitroubba86822013-11-23 00:34:26 +010029
30* coroutines and tasks based on ``yield from`` (:PEP:`380`), to help write
31 concurrent code in a sequential fashion;
32
Eli Benderskyb73c8332014-02-09 06:07:47 -080033* cancellation support for :class:`Future`\s and coroutines;
Antoine Pitroubba86822013-11-23 00:34:26 +010034
Victor Stinner9592edb2014-02-02 15:03:02 +010035* :ref:`synchronization primitives <asyncio-sync>` for use between coroutines in
Antoine Pitroubba86822013-11-23 00:34:26 +010036 a single thread, mimicking those in the :mod:`threading` module;
37
Guido van Rossumf0f5d382013-11-22 15:45:02 -080038* 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
Victor Stinner85a2be72013-12-03 15:04:36 +010042Table of content:
Antoine Pitroubba86822013-11-23 00:34:26 +010043
Victor Stinnerea3183f2013-12-03 01:08:00 +010044.. toctree::
45 :maxdepth: 3
Antoine Pitroubba86822013-11-23 00:34:26 +010046
Victor Stinnerea3183f2013-12-03 01:08:00 +010047 asyncio-eventloop.rst
48 asyncio-task.rst
49 asyncio-protocol.rst
Victor Stinner24f8ebf2014-01-23 11:05:01 +010050 asyncio-stream.rst
Victor Stinner08444382014-02-02 22:43:39 +010051 asyncio-subprocess.rst
Victor Stinnerea3183f2013-12-03 01:08:00 +010052 asyncio-sync.rst
Victor Stinnerdb39a0d2014-01-16 18:58:01 +010053 asyncio-dev.rst
Antoine Pitroubba86822013-11-23 00:34:26 +010054
Victor Stinner85a2be72013-12-03 15:04:36 +010055.. seealso::
56
57 The :mod:`asyncio` module was designed in the :PEP:`3156`. For a
58 motivational primer on transports and protocols, see :PEP:`3153`.
59