@@ -22,7 +22,7 @@ to simplify async code usage for common wide-spread scenarios.
2222Running an asyncio Program
2323==========================
2424
25- .. function :: run(coro, *, debug=None, loop_factory=None)
25+ .. function :: run(coro, *, debug=None, loop_factory=None, eager_tasks=False )
2626
2727 Execute *coro * in an asyncio event loop and return the result.
2828
@@ -45,10 +45,18 @@ Running an asyncio Program
4545 and should ideally only be called once. It is recommended to use
4646 *loop_factory * to configure the event loop.
4747
48+ If *eager_tasks * is ``True ``, the created loop is configured to use
49+ :ref: `eager-task-factory ` by default.
50+
4851 The executor is given a timeout duration of 5 minutes to shutdown.
4952 If the executor hasn't finished within that duration, a warning is
5053 emitted and the executor is closed.
5154
55+ .. note ::
56+
57+ Users concerned about performance are encouraged to experiment with
58+ ``eager_tasks=True `` in their code.
59+
5260 Example::
5361
5462 async def main():
@@ -74,11 +82,15 @@ Running an asyncio Program
7482
7583 *coro * can be any awaitable object.
7684
85+ .. versionchanged :: 3.16
86+
87+ Added *eager_tasks * parameter.
88+
7789
7890Runner context manager
7991======================
8092
81- .. class :: Runner(*, debug=None, loop_factory=None)
93+ .. class :: Runner(*, debug=None, loop_factory=None, eager_tasks=False )
8294
8395 A context manager that simplifies *multiple * async function calls in the same
8496 context.
@@ -95,6 +107,9 @@ Runner context manager
95107 current one. By default :func: `asyncio.new_event_loop ` is used and set as
96108 current event loop with :func: `asyncio.set_event_loop ` if *loop_factory * is ``None ``.
97109
110+ If *eager_tasks * is ``True ``, the created loop is configured to use
111+ :ref: `eager-task-factory ` by default.
112+
98113 Basically, :func: `asyncio.run ` example can be rewritten with the runner usage::
99114
100115 async def main():
@@ -104,8 +119,17 @@ Runner context manager
104119 with asyncio.Runner() as runner:
105120 runner.run(main())
106121
122+ .. note ::
123+
124+ Users concerned about performance are encouraged to experiment with
125+ ``eager_tasks=True `` in their code.
126+
107127 .. versionadded :: 3.11
108128
129+ .. versionchanged :: 3.16
130+
131+ Added *eager_tasks * parameter.
132+
109133 .. method :: run(coro, *, context=None)
110134
111135 Execute *coro * in the embedded event loop.
0 commit comments