blob: 690019859b0870a1c2096338a4bd44fa99286c11 [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
Nick Coghlanaf117ed2014-09-06 19:43:06 +10007.. note::
8
9 The asyncio package has been included in the standard library on a
10 :term:`provisional basis <provisional package>`. Backwards incompatible
11 changes (up to and including removal of the module) may occur if deemed
12 necessary by the core developers.
13
Guido van Rossum7a465642013-11-22 11:47:22 -080014.. versionadded:: 3.4
15
Guido van Rossumf8d0ff92013-11-22 16:53:25 -080016**Source code:** :source:`Lib/asyncio/`
17
18--------------
Guido van Rossum7a465642013-11-22 11:47:22 -080019
Antoine Pitroubba86822013-11-23 00:34:26 +010020This module provides infrastructure for writing single-threaded concurrent
21code using coroutines, multiplexing I/O access over sockets and other
22resources, running network clients and servers, and other related primitives.
Antoine Pitroubba86822013-11-23 00:34:26 +010023Here is a more detailed list of the package contents:
24
Victor Stinner9592edb2014-02-02 15:03:02 +010025* a pluggable :ref:`event loop <asyncio-event-loop>` with various system-specific
Antoine Pitroubba86822013-11-23 00:34:26 +010026 implementations;
27
Victor Stinner9592edb2014-02-02 15:03:02 +010028* :ref:`transport <asyncio-transport>` and :ref:`protocol <asyncio-protocol>` abstractions
Georg Brandlb7354a62014-10-29 10:57:37 +010029 (similar to those in `Twisted <https://twistedmatrix.com/trac/>`_);
Antoine Pitroubba86822013-11-23 00:34:26 +010030
31* concrete support for TCP, UDP, SSL, subprocess pipes, delayed calls, and
32 others (some may be system-dependent);
33
Brian Curtina1afeec2014-02-08 18:36:14 -060034* a :class:`Future` class that mimics the one in the :mod:`concurrent.futures`
Victor Stinner99c2ab42013-12-03 19:17:25 +010035 module, but adapted for use with the event loop;
Antoine Pitroubba86822013-11-23 00:34:26 +010036
37* coroutines and tasks based on ``yield from`` (:PEP:`380`), to help write
38 concurrent code in a sequential fashion;
39
Eli Benderskyb73c8332014-02-09 06:07:47 -080040* cancellation support for :class:`Future`\s and coroutines;
Antoine Pitroubba86822013-11-23 00:34:26 +010041
Victor Stinner9592edb2014-02-02 15:03:02 +010042* :ref:`synchronization primitives <asyncio-sync>` for use between coroutines in
Antoine Pitroubba86822013-11-23 00:34:26 +010043 a single thread, mimicking those in the :mod:`threading` module;
44
Guido van Rossumf0f5d382013-11-22 15:45:02 -080045* an interface for passing work off to a threadpool, for times when
46 you absolutely, positively have to use a library that makes blocking
47 I/O calls.
48
Terry Jan Reedy9ff41802014-07-24 02:59:02 -040049Table of contents:
Antoine Pitroubba86822013-11-23 00:34:26 +010050
Victor Stinnerea3183f2013-12-03 01:08:00 +010051.. toctree::
52 :maxdepth: 3
Antoine Pitroubba86822013-11-23 00:34:26 +010053
Victor Stinnerea3183f2013-12-03 01:08:00 +010054 asyncio-eventloop.rst
Victor Stinneraea82292014-07-08 23:42:38 +020055 asyncio-eventloops.rst
Victor Stinnerea3183f2013-12-03 01:08:00 +010056 asyncio-task.rst
57 asyncio-protocol.rst
Victor Stinner24f8ebf2014-01-23 11:05:01 +010058 asyncio-stream.rst
Victor Stinner08444382014-02-02 22:43:39 +010059 asyncio-subprocess.rst
Victor Stinnerea3183f2013-12-03 01:08:00 +010060 asyncio-sync.rst
Victor Stinnerdb39a0d2014-01-16 18:58:01 +010061 asyncio-dev.rst
Antoine Pitroubba86822013-11-23 00:34:26 +010062
Victor Stinner85a2be72013-12-03 15:04:36 +010063.. seealso::
64
Terry Jan Reedy9ff41802014-07-24 02:59:02 -040065 The :mod:`asyncio` module was designed in :PEP:`3156`. For a
Victor Stinner85a2be72013-12-03 15:04:36 +010066 motivational primer on transports and protocols, see :PEP:`3153`.
67