Guido van Rossum | 7a46564 | 2013-11-22 11:47:22 -0800 | [diff] [blame] | 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 | |
Guido van Rossum | f8d0ff9 | 2013-11-22 16:53:25 -0800 | [diff] [blame] | 9 | **Source code:** :source:`Lib/asyncio/` |
| 10 | |
| 11 | -------------- |
Guido van Rossum | 7a46564 | 2013-11-22 11:47:22 -0800 | [diff] [blame] | 12 | |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 13 | This module provides infrastructure for writing single-threaded concurrent |
| 14 | code using coroutines, multiplexing I/O access over sockets and other |
| 15 | resources, running network clients and servers, and other related primitives. |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 16 | Here is a more detailed list of the package contents: |
| 17 | |
Victor Stinner | 9592edb | 2014-02-02 15:03:02 +0100 | [diff] [blame^] | 18 | * a pluggable :ref:`event loop <asyncio-event-loop>` with various system-specific |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 19 | implementations; |
| 20 | |
Victor Stinner | 9592edb | 2014-02-02 15:03:02 +0100 | [diff] [blame^] | 21 | * :ref:`transport <asyncio-transport>` and :ref:`protocol <asyncio-protocol>` abstractions |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 22 | (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 | |
Victor Stinner | 99c2ab4 | 2013-12-03 19:17:25 +0100 | [diff] [blame] | 27 | * a :class:`Future` class that mimicks the one in the :mod:`concurrent.futures` |
| 28 | module, but adapted for use with the event loop; |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 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 Futures and coroutines; |
| 34 | |
Victor Stinner | 9592edb | 2014-02-02 15:03:02 +0100 | [diff] [blame^] | 35 | * :ref:`synchronization primitives <asyncio-sync>` for use between coroutines in |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 36 | a single thread, mimicking those in the :mod:`threading` module; |
| 37 | |
Guido van Rossum | f0f5d38 | 2013-11-22 15:45:02 -0800 | [diff] [blame] | 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 | |
Victor Stinner | 85a2be7 | 2013-12-03 15:04:36 +0100 | [diff] [blame] | 42 | Table of content: |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 43 | |
Victor Stinner | ea3183f | 2013-12-03 01:08:00 +0100 | [diff] [blame] | 44 | .. toctree:: |
| 45 | :maxdepth: 3 |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 46 | |
Victor Stinner | ea3183f | 2013-12-03 01:08:00 +0100 | [diff] [blame] | 47 | asyncio-eventloop.rst |
| 48 | asyncio-task.rst |
| 49 | asyncio-protocol.rst |
Victor Stinner | 24f8ebf | 2014-01-23 11:05:01 +0100 | [diff] [blame] | 50 | asyncio-stream.rst |
Victor Stinner | ea3183f | 2013-12-03 01:08:00 +0100 | [diff] [blame] | 51 | asyncio-sync.rst |
Victor Stinner | db39a0d | 2014-01-16 18:58:01 +0100 | [diff] [blame] | 52 | asyncio-dev.rst |
Antoine Pitrou | bba8682 | 2013-11-23 00:34:26 +0100 | [diff] [blame] | 53 | |
Victor Stinner | 85a2be7 | 2013-12-03 15:04:36 +0100 | [diff] [blame] | 54 | .. seealso:: |
| 55 | |
| 56 | The :mod:`asyncio` module was designed in the :PEP:`3156`. For a |
| 57 | motivational primer on transports and protocols, see :PEP:`3153`. |
| 58 | |