@@ -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)
25+ .. function :: run(coro, *, debug=None, loop_factory=None )
2626
2727 Execute the :term: `coroutine ` *coro * and return the result.
2828
@@ -37,9 +37,11 @@ Running an asyncio Program
3737 debug mode explicitly. ``None `` is used to respect the global
3838 :ref: `asyncio-debug-mode ` settings.
3939
40- This function always creates a new event loop and closes it at
41- the end. It should be used as a main entry point for asyncio
42- programs, and should ideally only be called once.
40+ If *loop_factory * is not ``None ``, it is used to create a new event loop;
41+ otherwise :func: `asyncio.new_event_loop ` is used. The loop is closed at the end.
42+ This function should be used as a main entry point for asyncio programs,
43+ and should ideally only be called once. It is recommended to use
44+ *loop_factory * to configure the event loop instead of policies.
4345
4446 The executor is given a timeout duration of 5 minutes to shutdown.
4547 If the executor hasn't finished within that duration, a warning is
@@ -62,6 +64,10 @@ Running an asyncio Program
6264
6365 *debug * is ``None `` by default to respect the global debug mode settings.
6466
67+ .. versionchanged :: 3.12
68+
69+ Added *loop_factory * parameter.
70+
6571
6672Runner context manager
6773======================
0 commit comments