bpo-34037: Fix test_asyncio failure and add loop.shutdown_default_executor() (GH-15735)
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index 8f7974b..2fd4cf3 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -167,6 +167,18 @@
.. versionadded:: 3.6
+.. coroutinemethod:: loop.shutdown_default_executor()
+
+ Schedule the closure of the default executor and wait for it to join all of
+ the threads in the :class:`ThreadPoolExecutor`. After calling this method, a
+ :exc:`RuntimeError` will be raised if :meth:`loop.run_in_executor` is called
+ while using the default executor.
+
+ Note that there is no need to call this function when
+ :func:`asyncio.run` is used.
+
+ .. versionadded:: 3.9
+
Scheduling callbacks
^^^^^^^^^^^^^^^^^^^^
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index 57e0e07..d932042 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -213,8 +213,8 @@
.. function:: run(coro, \*, debug=False)
This function runs the passed coroutine, taking care of
- managing the asyncio event loop and *finalizing asynchronous
- generators*.
+ managing the asyncio event loop, *finalizing asynchronous
+ generators*, and closing the threadpool.
This function cannot be called when another asyncio event loop is
running in the same thread.
@@ -229,6 +229,8 @@
**Important:** this function has been added to asyncio in
Python 3.7 on a :term:`provisional basis <provisional api>`.
+ .. versionchanged:: 3.9
+ Updated to use :meth:`loop.shutdown_default_executor`.
Creating Tasks
==============