Skip to content

Commit 2b0b017

Browse files
miss-islingtonCAM-Gerlach
authored andcommitted
gh-96377: Update asyncio policy doc intro paras to be clear and accurate (GH-97603)
Also fix up some cross-references in the asyncio docs. (cherry picked from commit cc0f3a1) Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent 8de3533 commit 2b0b017

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

Doc/library/asyncio-dev.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ that the event loop runs in.
109109

110110
There is currently no way to schedule coroutines or callbacks directly
111111
from a different process (such as one started with
112-
:mod:`multiprocessing`). The :ref:`Event Loop Methods <asyncio-event-loop>`
112+
:mod:`multiprocessing`). The :ref:`asyncio-event-loop-methods`
113113
section lists APIs that can read from pipes and watch file descriptors
114114
without blocking the event loop. In addition, asyncio's
115115
:ref:`Subprocess <asyncio-subprocess>` APIs provide a way to start a

Doc/library/asyncio-eventloop.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.. currentmodule:: asyncio
22

33

4+
.. _asyncio-event-loop:
5+
46
==========
57
Event Loop
68
==========
@@ -92,7 +94,7 @@ This documentation page contains the following sections:
9294
loop APIs.
9395

9496

95-
.. _asyncio-event-loop:
97+
.. _asyncio-event-loop-methods:
9698

9799
Event Loop Methods
98100
==================
@@ -1616,6 +1618,7 @@ Do not instantiate the class directly.
16161618

16171619

16181620
.. _asyncio-event-loops:
1621+
.. _asyncio-event-loop-implementations:
16191622

16201623
Event Loop Implementations
16211624
==========================
@@ -1665,7 +1668,7 @@ on Unix and :class:`ProactorEventLoop` on Windows.
16651668

16661669
Abstract base class for asyncio-compliant event loops.
16671670

1668-
The :ref:`Event Loop Methods <asyncio-event-loop>` section lists all
1671+
The :ref:`asyncio-event-loop-methods` section lists all
16691672
methods that an alternative implementation of ``AbstractEventLoop``
16701673
should have defined.
16711674

Doc/library/asyncio-llapi-index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Event Loop Methods
3737
==================
3838

3939
See also the main documentation section about the
40-
:ref:`event loop methods <asyncio-event-loop>`.
40+
:ref:`asyncio-event-loop-methods`.
4141

4242
.. rubric:: Lifecycle
4343
.. list-table::

Doc/library/asyncio-policy.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Policies
88
========
99

10-
An event loop policy is a global object
10+
An event loop policy is a global (per-interpreter) object
1111
used to get and set the current :ref:`event loop <asyncio-event-loop>`,
1212
as well as create new event loops.
1313
The default policy can be :ref:`replaced <asyncio-policy-get-set>` with
@@ -16,18 +16,20 @@ to use different event loop implementations,
1616
or substituted by a :ref:`custom policy <asyncio-custom-policies>`
1717
that can override these behaviors.
1818

19-
A policy defines the notion of *context* and manages a
20-
separate event loop per context. The default policy
21-
defines *context* to be the current thread.
19+
The :ref:`policy object <asyncio-policy-objects>`
20+
gets and sets a separate event loop per *context*.
21+
This is per-thread by default,
22+
though custom policies could define *context* differently.
2223

23-
By using a custom event loop policy, the behavior of
24-
:func:`get_event_loop`, :func:`set_event_loop`, and
25-
:func:`new_event_loop` functions can be customized.
24+
Custom event loop policies can control the behavior of
25+
:func:`get_event_loop`, :func:`set_event_loop`, and :func:`new_event_loop`.
2626

2727
Policy objects should implement the APIs defined
2828
in the :class:`AbstractEventLoopPolicy` abstract base class.
2929

3030

31+
.. _asyncio-policy-get-set:
32+
3133
Getting and Setting the Policy
3234
==============================
3335

@@ -45,6 +47,8 @@ for the current process:
4547
If *policy* is set to ``None``, the default policy is restored.
4648

4749

50+
.. _asyncio-policy-objects:
51+
4852
Policy Objects
4953
==============
5054

@@ -91,6 +95,8 @@ The abstract event loop policy base class is defined as follows:
9195
This function is Unix specific.
9296

9397

98+
.. _asyncio-policy-builtin:
99+
94100
asyncio ships with the following built-in policies:
95101

96102

@@ -122,6 +128,7 @@ asyncio ships with the following built-in policies:
122128

123129
.. availability:: Windows.
124130

131+
125132
.. _asyncio-watchers:
126133

127134
Process Watchers
@@ -275,6 +282,8 @@ implementation used by the asyncio event loop:
275282
.. versionadded:: 3.9
276283

277284

285+
.. _asyncio-custom-policies:
286+
278287
Custom Policies
279288
===============
280289

0 commit comments

Comments
 (0)