Commit 394374e3 authored by Yury Selivanov's avatar Yury Selivanov Committed by GitHub

bpo-33649: Add low-level APIs index. (GH-9364)

parent c6fd1c1c
.. currentmodule:: asyncio .. currentmodule:: asyncio
===================== ====================
High-level APIs Index High-level API Index
===================== ====================
This page lists all high-level async/await enabled asyncio APIs. This page lists all high-level async/await enabled asyncio APIs.
...@@ -16,6 +16,7 @@ await on multiple things with timeouts. ...@@ -16,6 +16,7 @@ await on multiple things with timeouts.
.. list-table:: .. list-table::
:widths: 50 50 :widths: 50 50
:class: full-width-table
* - :func:`run` * - :func:`run`
- Create event loop, run a coroutine, close the loop. - Create event loop, run a coroutine, close the loop.
...@@ -36,7 +37,7 @@ await on multiple things with timeouts. ...@@ -36,7 +37,7 @@ await on multiple things with timeouts.
- Shield from cancellation. - Shield from cancellation.
* - ``await`` :func:`wait` * - ``await`` :func:`wait`
- Monitor for completeness. - Monitor for completion.
* - :func:`current_task` * - :func:`current_task`
- Return the current Task. - Return the current Task.
...@@ -47,6 +48,12 @@ await on multiple things with timeouts. ...@@ -47,6 +48,12 @@ await on multiple things with timeouts.
* - :class:`Task` * - :class:`Task`
- Task object. - Task object.
* - :func:`run_coroutine_threadsafe`
- Schedule a coroutine from another OS thread.
* - ``for in`` :func:`as_completed`
- Monitor for completion with a ``for`` loop.
.. rubric:: Examples .. rubric:: Examples
...@@ -72,6 +79,7 @@ implement connection pools, and pub/sub patterns. ...@@ -72,6 +79,7 @@ implement connection pools, and pub/sub patterns.
.. list-table:: .. list-table::
:widths: 50 50 :widths: 50 50
:class: full-width-table
* - :class:`Queue` * - :class:`Queue`
- A FIFO queue. - A FIFO queue.
...@@ -98,6 +106,7 @@ Utilities to spawn subprocesses and run shell commands. ...@@ -98,6 +106,7 @@ Utilities to spawn subprocesses and run shell commands.
.. list-table:: .. list-table::
:widths: 50 50 :widths: 50 50
:class: full-width-table
* - ``await`` :func:`create_subprocess_exec` * - ``await`` :func:`create_subprocess_exec`
- Create a subprocess. - Create a subprocess.
...@@ -121,6 +130,7 @@ High-level APIs to work with network IO. ...@@ -121,6 +130,7 @@ High-level APIs to work with network IO.
.. list-table:: .. list-table::
:widths: 50 50 :widths: 50 50
:class: full-width-table
* - ``await`` :func:`open_connection` * - ``await`` :func:`open_connection`
- Establish a TCP connection. - Establish a TCP connection.
...@@ -156,6 +166,7 @@ Threading-like synchronization primitives that can be used in Tasks. ...@@ -156,6 +166,7 @@ Threading-like synchronization primitives that can be used in Tasks.
.. list-table:: .. list-table::
:widths: 50 50 :widths: 50 50
:class: full-width-table
* - :class:`Lock` * - :class:`Lock`
- A mutex lock. - A mutex lock.
...@@ -186,6 +197,7 @@ Exceptions ...@@ -186,6 +197,7 @@ Exceptions
.. list-table:: .. list-table::
:widths: 50 50 :widths: 50 50
:class: full-width-table
* - :exc:`asyncio.TimeoutError` * - :exc:`asyncio.TimeoutError`
......
...@@ -980,7 +980,7 @@ Availability: UNIX. ...@@ -980,7 +980,7 @@ Availability: UNIX.
Executing code in thread or process pools Executing code in thread or process pools
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. method:: loop.run_in_executor(executor, func, \*args) .. coroutinemethod:: loop.run_in_executor(executor, func, \*args)
Arrange for a *func* to be called in the specified executor. Arrange for a *func* to be called in the specified executor.
...@@ -1418,7 +1418,7 @@ need to be written this way; consider using high-level functions ...@@ -1418,7 +1418,7 @@ need to be written this way; consider using high-level functions
like :func:`asyncio.run`. like :func:`asyncio.run`.
.. _asyncio-hello-world-callback: .. _asyncio_example_lowlevel_helloworld:
Hello World with call_soon() Hello World with call_soon()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -1451,7 +1451,7 @@ event loop:: ...@@ -1451,7 +1451,7 @@ event loop::
example created with a coroutine and the :func:`run` function. example created with a coroutine and the :func:`run` function.
.. _asyncio-date-callback: .. _asyncio_example_call_later:
Display the current date with call_later() Display the current date with call_later()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -1488,7 +1488,7 @@ during 5 seconds, and then stops the event loop:: ...@@ -1488,7 +1488,7 @@ during 5 seconds, and then stops the event loop::
created with a coroutine and the :func:`run` function. created with a coroutine and the :func:`run` function.
.. _asyncio-watch-read-event: .. _asyncio_example_watch_fd:
Watch a file descriptor for read events Watch a file descriptor for read events
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -1531,15 +1531,17 @@ Wait until a file descriptor received some data using the ...@@ -1531,15 +1531,17 @@ Wait until a file descriptor received some data using the
.. seealso:: .. seealso::
* A similar :ref:`example <asyncio-register-socket>` * A similar :ref:`example <asyncio_example_create_connection>`
using transports, protocols, and the using transports, protocols, and the
:meth:`loop.create_connection` method. :meth:`loop.create_connection` method.
* Another similar :ref:`example <asyncio-register-socket-streams>` * Another similar :ref:`example <asyncio_example_create_connection-streams>`
using the high-level :func:`asyncio.open_connection` function using the high-level :func:`asyncio.open_connection` function
and streams. and streams.
.. _asyncio_example_unix_signals:
Set signal handlers for SIGINT and SIGTERM Set signal handlers for SIGINT and SIGTERM
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
...@@ -191,6 +191,8 @@ Future Object ...@@ -191,6 +191,8 @@ Future Object
.. versionadded:: 3.7 .. versionadded:: 3.7
.. _asyncio_example_future:
This example creates a Future object, creates and schedules an This example creates a Future object, creates and schedules an
asynchronous Task to set result for the Future, and waits until asynchronous Task to set result for the Future, and waits until
the Future has a result:: the Future has a result::
......
This diff is collapsed.
...@@ -707,7 +707,7 @@ factories passed to the :meth:`loop.subprocess_exec` and ...@@ -707,7 +707,7 @@ factories passed to the :meth:`loop.subprocess_exec` and
Examples Examples
======== ========
.. _asyncio-tcp-echo-server-protocol: .. _asyncio_example_tcp_echo_server_protocol:
TCP Echo Server TCP Echo Server
--------------- ---------------
...@@ -756,7 +756,7 @@ received data, and close the connection:: ...@@ -756,7 +756,7 @@ received data, and close the connection::
The :ref:`TCP echo server using streams <asyncio-tcp-echo-server-streams>` The :ref:`TCP echo server using streams <asyncio-tcp-echo-server-streams>`
example uses the high-level :func:`asyncio.start_server` function. example uses the high-level :func:`asyncio.start_server` function.
.. _asyncio-tcp-echo-client-protocol: .. _asyncio_example_tcp_echo_client_protocol:
TCP Echo Client TCP Echo Client
--------------- ---------------
...@@ -914,7 +914,7 @@ method, sends data and closes the transport when it receives the answer:: ...@@ -914,7 +914,7 @@ method, sends data and closes the transport when it receives the answer::
asyncio.run(main()) asyncio.run(main())
.. _asyncio-register-socket: .. _asyncio_example_create_connection:
Connecting Existing Sockets Connecting Existing Sockets
--------------------------- ---------------------------
...@@ -973,14 +973,14 @@ Wait until a socket receives data using the ...@@ -973,14 +973,14 @@ Wait until a socket receives data using the
.. seealso:: .. seealso::
The :ref:`watch a file descriptor for read events The :ref:`watch a file descriptor for read events
<asyncio-watch-read-event>` example uses the low-level <asyncio_example_watch_fd>` example uses the low-level
:meth:`loop.add_reader` method to register an FD. :meth:`loop.add_reader` method to register an FD.
The :ref:`register an open socket to wait for data using streams The :ref:`register an open socket to wait for data using streams
<asyncio-register-socket-streams>` example uses high-level streams <asyncio_example_create_connection-streams>` example uses high-level streams
created by the :func:`open_connection` function in a coroutine. created by the :func:`open_connection` function in a coroutine.
.. _asyncio-subprocess-proto-example: .. _asyncio_example_subprocess_proto:
loop.subprocess_exec() and SubprocessProtocol loop.subprocess_exec() and SubprocessProtocol
--------------------------------------------- ---------------------------------------------
...@@ -1037,3 +1037,6 @@ The subprocess is created by th :meth:`loop.subprocess_exec` method:: ...@@ -1037,3 +1037,6 @@ The subprocess is created by th :meth:`loop.subprocess_exec` method::
date = asyncio.run(get_date()) date = asyncio.run(get_date())
print(f"Current date: {date}") print(f"Current date: {date}")
See also the :ref:`same example <asyncio_example_create_subprocess_exec>`
written using high-level APIs.
...@@ -348,7 +348,7 @@ TCP echo client using the :func:`asyncio.open_connection` function:: ...@@ -348,7 +348,7 @@ TCP echo client using the :func:`asyncio.open_connection` function::
.. seealso:: .. seealso::
The :ref:`TCP echo client protocol <asyncio-tcp-echo-client-protocol>` The :ref:`TCP echo client protocol <asyncio_example_tcp_echo_client_protocol>`
example uses the low-level :meth:`loop.create_connection` method. example uses the low-level :meth:`loop.create_connection` method.
...@@ -390,7 +390,7 @@ TCP echo server using the :func:`asyncio.start_server` function:: ...@@ -390,7 +390,7 @@ TCP echo server using the :func:`asyncio.start_server` function::
.. seealso:: .. seealso::
The :ref:`TCP echo server protocol <asyncio-tcp-echo-server-protocol>` The :ref:`TCP echo server protocol <asyncio_example_tcp_echo_server_protocol>`
example uses the :meth:`loop.create_server` method. example uses the :meth:`loop.create_server` method.
...@@ -444,7 +444,7 @@ or with HTTPS:: ...@@ -444,7 +444,7 @@ or with HTTPS::
python example.py https://example.com/path/page.html python example.py https://example.com/path/page.html
.. _asyncio-register-socket-streams: .. _asyncio_example_create_connection-streams:
Register an open socket to wait for data using streams Register an open socket to wait for data using streams
------------------------------------------------------ ------------------------------------------------------
...@@ -484,9 +484,9 @@ Coroutine waiting until a socket receives data using the ...@@ -484,9 +484,9 @@ Coroutine waiting until a socket receives data using the
.. seealso:: .. seealso::
The :ref:`register an open socket to wait for data using a protocol The :ref:`register an open socket to wait for data using a protocol
<asyncio-register-socket>` example uses a low-level protocol and <asyncio_example_create_connection>` example uses a low-level protocol and
the :meth:`loop.create_connection` method. the :meth:`loop.create_connection` method.
The :ref:`watch a file descriptor for read events The :ref:`watch a file descriptor for read events
<asyncio-watch-read-event>` example uses the low-level <asyncio_example_watch_fd>` example uses the low-level
:meth:`loop.add_reader` method to watch a file descriptor. :meth:`loop.add_reader` method to watch a file descriptor.
...@@ -318,6 +318,8 @@ An example using the :class:`~asyncio.subprocess.Process` class to ...@@ -318,6 +318,8 @@ An example using the :class:`~asyncio.subprocess.Process` class to
control a subprocess and the :class:`StreamReader` class to read from control a subprocess and the :class:`StreamReader` class to read from
the *stdout*. the *stdout*.
.. _asyncio_example_create_subprocess_exec:
The subprocess is created by the :func:`create_subprocess_exec` The subprocess is created by the :func:`create_subprocess_exec`
function:: function::
...@@ -349,5 +351,5 @@ function:: ...@@ -349,5 +351,5 @@ function::
print(f"Current date: {date}") print(f"Current date: {date}")
See also the :ref:`same example <asyncio-subprocess-proto-example>` See also the :ref:`same example <asyncio_example_subprocess_proto>`
written using low-level APIs. written using low-level APIs.
...@@ -130,7 +130,7 @@ Running an asyncio Program ...@@ -130,7 +130,7 @@ Running an asyncio Program
programs, and should ideally only be called once. programs, and should ideally only be called once.
.. versionadded:: 3.7 .. versionadded:: 3.7
**Important:** this has been been added to asyncio in Python 3.7 **Important:** this has been added to asyncio in Python 3.7
on a :term:`provisional basis <provisional api>`. on a :term:`provisional basis <provisional api>`.
...@@ -188,7 +188,7 @@ Sleeping ...@@ -188,7 +188,7 @@ Sleeping
Running Tasks Concurrently Running Tasks Concurrently
========================== ==========================
.. coroutinefunction:: gather(\*fs, loop=None, return_exceptions=False) .. function:: gather(\*fs, loop=None, return_exceptions=False)
Return a Future aggregating results from the given coroutine objects, Return a Future aggregating results from the given coroutine objects,
Tasks, or Futures. Tasks, or Futures.
......
...@@ -43,12 +43,13 @@ as well as **low-level** APIs for *library and framework developers* to: ...@@ -43,12 +43,13 @@ as well as **low-level** APIs for *library and framework developers* to:
with async/await syntax. with async/await syntax.
Reference .. We use the "rubric" directive here to avoid creating
--------- the "Reference" subsection in the TOC.
.. rubric:: High-level APIs .. rubric:: Reference
.. toctree:: .. toctree::
:caption: High-level APIs
:maxdepth: 1 :maxdepth: 1
asyncio-task.rst asyncio-task.rst
...@@ -58,9 +59,8 @@ Reference ...@@ -58,9 +59,8 @@ Reference
asyncio-queue.rst asyncio-queue.rst
asyncio-exceptions.rst asyncio-exceptions.rst
.. rubric:: Low-level APIs
.. toctree:: .. toctree::
:caption: Low-level APIs
:maxdepth: 1 :maxdepth: 1
asyncio-eventloop.rst asyncio-eventloop.rst
...@@ -69,10 +69,10 @@ Reference ...@@ -69,10 +69,10 @@ Reference
asyncio-policy.rst asyncio-policy.rst
asyncio-platforms.rst asyncio-platforms.rst
.. rubric:: Guides and Tutorials
.. toctree:: .. toctree::
:caption: Guides and Tutorials
:maxdepth: 1 :maxdepth: 1
asyncio-api-index.rst asyncio-api-index.rst
asyncio-llapi-index.rst
asyncio-dev.rst asyncio-dev.rst
...@@ -21,5 +21,14 @@ ...@@ -21,5 +21,14 @@
{% if pagename == 'whatsnew/changelog' and not embedded %} {% if pagename == 'whatsnew/changelog' and not embedded %}
<script type="text/javascript" src="{{ pathto('_static/changelog_search.js', 1) }}"></script>{% endif %} <script type="text/javascript" src="{{ pathto('_static/changelog_search.js', 1) }}"></script>{% endif %}
{% endif %} {% endif %}
{# custom CSS; used in asyncio docs! #}
<style>
@media only screen {{ "{" }}
table.full-width-table {{ "{" }}
width: 100%;
{{ "}" }}
{{ "}" }}
</style>
{{ super() }} {{ super() }}
{% endblock %} {% endblock %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment