77Policies
88========
99
10- An event loop policy is a global per-process object that controls
11- the management of the event loop. Each event loop has a default
12- policy, which can be changed and customized using the policy API.
13-
14- A policy defines the notion of *context * and manages a
15- separate event loop per context. The default policy
16- defines *context * to be the current thread.
17-
18- By using a custom event loop policy, the behavior of
19- :func: `get_event_loop `, :func: `set_event_loop `, and
20- :func: `new_event_loop ` functions can be customized.
10+ An event loop policy is a global (per-interpreter) object
11+ used to get and set the current :ref: `event loop <asyncio-event-loop >`,
12+ as well as create new event loops.
13+ The default policy can be :ref: `replaced <asyncio-policy-get-set >` with
14+ :ref: `built-in alternatives <asyncio-policy-builtin >`
15+ to use different event loop implementations,
16+ or substituted by a :ref: `custom policy <asyncio-custom-policies >`
17+ that can override these behaviors.
18+
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.
23+
24+ Custom event loop policies can control the behavior of
25+ :func: `get_event_loop `, :func: `set_event_loop `, and :func: `new_event_loop `.
2126
2227Policy objects should implement the APIs defined
2328in the :class: `AbstractEventLoopPolicy ` abstract base class.
2429
2530
31+ .. _asyncio-policy-get-set :
32+
2633Getting and Setting the Policy
2734==============================
2835
@@ -40,6 +47,8 @@ for the current process:
4047 If *policy * is set to ``None ``, the default policy is restored.
4148
4249
50+ .. _asyncio-policy-objects :
51+
4352Policy Objects
4453==============
4554
@@ -86,6 +95,8 @@ The abstract event loop policy base class is defined as follows:
8695 This function is Unix specific.
8796
8897
98+ .. _asyncio-policy-builtin :
99+
89100asyncio ships with the following built-in policies:
90101
91102
@@ -117,6 +128,7 @@ asyncio ships with the following built-in policies:
117128
118129 .. availability :: Windows.
119130
131+
120132.. _asyncio-watchers :
121133
122134Process Watchers
@@ -270,6 +282,8 @@ implementation used by the asyncio event loop:
270282 .. versionadded :: 3.9
271283
272284
285+ .. _asyncio-custom-policies :
286+
273287Custom Policies
274288===============
275289
0 commit comments