@@ -22,7 +22,7 @@ to simplify async code usage for common wide-spread scenarios.
22
22
Running an asyncio Program
23
23
==========================
24
24
25
- .. function :: run(coro, *, debug=None)
25
+ .. function :: run(coro, *, debug=None, loop_factory=None )
26
26
27
27
Execute the :term: `coroutine ` *coro * and return the result.
28
28
@@ -37,9 +37,11 @@ Running an asyncio Program
37
37
debug mode explicitly. ``None `` is used to respect the global
38
38
:ref: `asyncio-debug-mode ` settings.
39
39
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.
43
45
44
46
The executor is given a timeout duration of 5 minutes to shutdown.
45
47
If the executor hasn't finished within that duration, a warning is
@@ -62,6 +64,10 @@ Running an asyncio Program
62
64
63
65
*debug * is ``None `` by default to respect the global debug mode settings.
64
66
67
+ .. versionchanged :: 3.12
68
+
69
+ Added *loop_factory * parameter.
70
+
65
71
66
72
Runner context manager
67
73
======================
0 commit comments