summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-11-14 18:18:51 (GMT)
committerGitHub <noreply@github.com>2022-11-14 18:18:51 (GMT)
commitf63002755d3b7c0bb2e452f158769f19fcf3b850 (patch)
treee5d4dd832ee63f246a72bcc78a9dda88fad4e262 /Doc/library
parentf5e326e2b6b3f008ed71ccf9e6c3e18a6618ea45 (diff)
downloadcpython-f63002755d3b7c0bb2e452f158769f19fcf3b850.zip
cpython-f63002755d3b7c0bb2e452f158769f19fcf3b850.tar.gz
cpython-f63002755d3b7c0bb2e452f158769f19fcf3b850.tar.bz2
GH-99388: add `loop_factory` parameter to `asyncio.run` (#99462)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/asyncio-runner.rst14
1 files changed, 10 insertions, 4 deletions
diff --git a/Doc/library/asyncio-runner.rst b/Doc/library/asyncio-runner.rst
index c43d664..b68b257 100644
--- a/Doc/library/asyncio-runner.rst
+++ b/Doc/library/asyncio-runner.rst
@@ -22,7 +22,7 @@ to simplify async code usage for common wide-spread scenarios.
Running an asyncio Program
==========================
-.. function:: run(coro, *, debug=None)
+.. function:: run(coro, *, debug=None, loop_factory=None)
Execute the :term:`coroutine` *coro* and return the result.
@@ -37,9 +37,11 @@ Running an asyncio Program
debug mode explicitly. ``None`` is used to respect the global
:ref:`asyncio-debug-mode` settings.
- This function always creates a new event loop and closes it at
- the end. It should be used as a main entry point for asyncio
- programs, and should ideally only be called once.
+ If *loop_factory* is not ``None``, it is used to create a new event loop;
+ otherwise :func:`asyncio.new_event_loop` is used. The loop is closed at the end.
+ This function should be used as a main entry point for asyncio programs,
+ and should ideally only be called once. It is recommended to use
+ *loop_factory* to configure the event loop instead of policies.
The executor is given a timeout duration of 5 minutes to shutdown.
If the executor hasn't finished within that duration, a warning is
@@ -62,6 +64,10 @@ Running an asyncio Program
*debug* is ``None`` by default to respect the global debug mode settings.
+ .. versionchanged:: 3.12
+
+ Added *loop_factory* parameter.
+
Runner context manager
======================