Event Loop
==========
+**Source code:** :source:`Lib/asyncio/events.py`,
+:source:`Lib/asyncio/base_events.py`
+
+------------------------------------
.. rubric:: Preface
Exceptions
==========
+**Source code:** :source:`Lib/asyncio/exceptions.py`
+
+----------------------------------------------------
.. exception:: TimeoutError
Futures
=======
+**Source code:** :source:`Lib/asyncio/futures.py`,
+:source:`Lib/asyncio/base_futures.py`
+
+-------------------------------------
+
*Future* objects are used to bridge **low-level callback-based code**
with high-level async/await code.
Windows
=======
+**Source code:** :source:`Lib/asyncio/proactor_events.py`,
+:source:`Lib/asyncio/windows_events.py`,
+:source:`Lib/asyncio/windows_utils.py`
+
+--------------------------------------
+
.. versionchanged:: 3.8
On Windows, :class:`ProactorEventLoop` is now the default event loop.
Transports
==========
+**Source code:** :source:`Lib/asyncio/transports.py`
+
+----------------------------------------------------
+
Transports are classes provided by :mod:`asyncio` in order to abstract
various kinds of communication channels.
Protocols
=========
+**Source code:** :source:`Lib/asyncio/protocols.py`
+
+---------------------------------------------------
+
asyncio provides a set of abstract base classes that should be used
to implement network protocols. Those classes are meant to be used
together with :ref:`transports <asyncio-transport>`.
Queues
======
+**Source code:** :source:`Lib/asyncio/queues.py`
+
+------------------------------------------------
+
asyncio queues are designed to be similar to classes of the
:mod:`queue` module. Although asyncio queues are not thread-safe,
they are designed to be used specifically in async/await code.
Streams
=======
+**Source code:** :source:`Lib/asyncio/streams.py`
+
+-------------------------------------------------
+
Streams are high-level async/await-ready primitives to work with
network connections. Streams allow sending and receiving data without
using callbacks or low-level protocols and transports.
Subprocesses
============
+**Source code:** :source:`Lib/asyncio/subprocess.py`,
+:source:`Lib/asyncio/base_subprocess.py`
+
+----------------------------------------
+
This section describes high-level async/await asyncio APIs to
create and manage subprocesses.
Synchronization Primitives
==========================
+**Source code:** :source:`Lib/asyncio/locks.py`
+
+-----------------------------------------------
+
asyncio synchronization primitives are designed to be similar to
those of the :mod:`threading` module with two important caveats:
Coroutines
==========
-Coroutines declared with async/await syntax is the preferred way of
-writing asyncio applications. For example, the following snippet
-of code (requires Python 3.7+) prints "hello", waits 1 second,
+:term:`Coroutines <coroutine>` declared with the async/await syntax is the
+preferred way of writing asyncio applications. For example, the following
+snippet of code (requires Python 3.7+) prints "hello", waits 1 second,
and then prints "world"::
>>> import asyncio
.. versionchanged:: 3.9
Updated to use :meth:`loop.shutdown_default_executor`.
+ .. note::
+ The source code for ``asyncio.run()`` can be found in
+ :source:`Lib/asyncio/runners.py`.
+
Creating Tasks
==============
.. module:: asyncio
:synopsis: Asynchronous I/O.
---------------
+-------------------------------
.. sidebar:: Hello World!
asyncio-api-index.rst
asyncio-llapi-index.rst
asyncio-dev.rst
+
+.. note::
+ The source code for asyncio can be found in :source:`Lib/asyncio/`.