blob: 7895826c65a0647f3d870582a22641b5658c4864 [file] [log] [blame]
Yury Selivanov3faaa882018-09-14 13:32:07 -07001:mod:`asyncio` --- Asynchronous I/O
2===================================
Guido van Rossum7a465642013-11-22 11:47:22 -08003
4.. module:: asyncio
Yury Selivanov3faaa882018-09-14 13:32:07 -07005 :synopsis: Asynchronous I/O.
Terry Jan Reedyfa089b92016-06-11 15:02:54 -04006
Guido van Rossumf8d0ff92013-11-22 16:53:25 -08007--------------
Guido van Rossum7a465642013-11-22 11:47:22 -08008
Yury Selivanov6c731642018-09-14 14:57:39 -07009asyncio is a library to write **concurrent** code using
10**async/await** syntax.
Yury Selivanov3faaa882018-09-14 13:32:07 -070011
Yury Selivanov6c731642018-09-14 14:57:39 -070012asyncio is used as a foundation for multiple Python asynchronous
13frameworks that provide high-performance network and web-servers,
14database connection libraries, distributed task queues, etc.
Antoine Pitroubba86822013-11-23 00:34:26 +010015
Yury Selivanov6c731642018-09-14 14:57:39 -070016asyncio is often a perfect fit for IO-bound and high-level
17**structured** network code.
Antoine Pitroubba86822013-11-23 00:34:26 +010018
Yury Selivanov6c731642018-09-14 14:57:39 -070019asyncio provides a set of **high-level** APIs to:
Antoine Pitroubba86822013-11-23 00:34:26 +010020
Yury Selivanov6c731642018-09-14 14:57:39 -070021* :ref:`run Python coroutines <coroutine>` concurrently and
22 have full control over their execution;
Antoine Pitroubba86822013-11-23 00:34:26 +010023
Yury Selivanov6c731642018-09-14 14:57:39 -070024* perform :ref:`network IO and IPC <asyncio-streams>`;
Antoine Pitroubba86822013-11-23 00:34:26 +010025
Yury Selivanov6c731642018-09-14 14:57:39 -070026* control :ref:`subprocesses <asyncio-subprocess>`;
Antoine Pitroubba86822013-11-23 00:34:26 +010027
Yury Selivanov6c731642018-09-14 14:57:39 -070028* distribute tasks via :ref:`queues <asyncio-queues>`;
Antoine Pitroubba86822013-11-23 00:34:26 +010029
Yury Selivanov6c731642018-09-14 14:57:39 -070030* :ref:`synchronize <asyncio-sync>` concurrent code;
Antoine Pitroubba86822013-11-23 00:34:26 +010031
Yury Selivanov6c731642018-09-14 14:57:39 -070032as well as **low-level** APIs for *library and framework developers* to:
Guido van Rossumf0f5d382013-11-22 15:45:02 -080033
Yury Selivanov6c731642018-09-14 14:57:39 -070034* create and manage :ref:`event loops <asyncio-event-loop>`, which
Yury Selivanov805e27e2018-09-14 16:57:11 -070035 provide asynchronous APIs for :meth:`networking <loop.create_server>`,
36 running :meth:`subprocesses <loop.subprocess_exec>`,
37 handling :meth:`OS signals <loop.add_signal_handler>`, etc;
Victor Stinner532c69a2015-02-25 14:23:51 +010038
Yury Selivanov6c731642018-09-14 14:57:39 -070039* implement efficient protocols using
40 :ref:`transports <asyncio-transports-protocols>`;
41
42* :ref:`bridge <asyncio-futures>` callback-based libraries and code
43 with async/await syntax.
44
45
Yury Selivanov394374e2018-09-17 15:35:24 -040046.. We use the "rubric" directive here to avoid creating
47 the "Reference" subsection in the TOC.
Yury Selivanov6c731642018-09-14 14:57:39 -070048
Yury Selivanov394374e2018-09-17 15:35:24 -040049.. rubric:: Reference
Antoine Pitroubba86822013-11-23 00:34:26 +010050
Victor Stinnerea3183f2013-12-03 01:08:00 +010051.. toctree::
Yury Selivanov394374e2018-09-17 15:35:24 -040052 :caption: High-level APIs
Yury Selivanov3faaa882018-09-14 13:32:07 -070053 :maxdepth: 1
54
55 asyncio-task.rst
56 asyncio-stream.rst
57 asyncio-sync.rst
58 asyncio-subprocess.rst
59 asyncio-queue.rst
60 asyncio-exceptions.rst
61
Yury Selivanov3faaa882018-09-14 13:32:07 -070062.. toctree::
Yury Selivanov394374e2018-09-17 15:35:24 -040063 :caption: Low-level APIs
Yury Selivanov3faaa882018-09-14 13:32:07 -070064 :maxdepth: 1
Antoine Pitroubba86822013-11-23 00:34:26 +010065
Victor Stinnerea3183f2013-12-03 01:08:00 +010066 asyncio-eventloop.rst
Yury Selivanov3faaa882018-09-14 13:32:07 -070067 asyncio-future.rst
68 asyncio-protocol.rst
Yury Selivanov7c7605f2018-09-11 09:54:40 -070069 asyncio-policy.rst
70 asyncio-platforms.rst
Yury Selivanov3faaa882018-09-14 13:32:07 -070071
Yury Selivanov3faaa882018-09-14 13:32:07 -070072.. toctree::
Yury Selivanov394374e2018-09-17 15:35:24 -040073 :caption: Guides and Tutorials
Yury Selivanov3faaa882018-09-14 13:32:07 -070074 :maxdepth: 1
75
Yury Selivanov7372c3b2018-09-14 15:11:24 -070076 asyncio-api-index.rst
Yury Selivanov394374e2018-09-17 15:35:24 -040077 asyncio-llapi-index.rst
Victor Stinnerdb39a0d2014-01-16 18:58:01 +010078 asyncio-dev.rst