From c65a82af4c0ddfcd599bf090414a40896113db41 Mon Sep 17 00:00:00 2001 From: AN Long Date: Wed, 3 Jul 2024 22:28:28 +0800 Subject: [PATCH 1/4] Clarify what is the default executor for asyncio.run_in_executor --- Doc/library/asyncio-eventloop.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 1d79f78e8e1b67..f2a061a6de2d5d 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1260,8 +1260,11 @@ Executing code in thread or process pools Arrange for *func* to be called in the specified executor. - The *executor* argument should be an :class:`concurrent.futures.Executor` - instance. The default executor is used if *executor* is ``None``. + The *executor* argument should be a :class:`concurrent.futures.Executor` + instance. The default executor, which is + :class:`concurrent.futures.ThreadPoolExecutor` if not modified + by :meth:`loop.set_default_executor`, will be used + if *executor* is ``None``. Example:: From 48200b7eda42372b23adfd997fc0cc60470db919 Mon Sep 17 00:00:00 2001 From: AN Long Date: Thu, 4 Jul 2024 09:12:34 +0800 Subject: [PATCH 2/4] Update Doc/library/asyncio-eventloop.rst Co-authored-by: Kumar Aditya --- Doc/library/asyncio-eventloop.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index f2a061a6de2d5d..4ea72e4baf98d5 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1261,10 +1261,8 @@ Executing code in thread or process pools Arrange for *func* to be called in the specified executor. The *executor* argument should be a :class:`concurrent.futures.Executor` - instance. The default executor, which is - :class:`concurrent.futures.ThreadPoolExecutor` if not modified - by :meth:`loop.set_default_executor`, will be used - if *executor* is ``None``. + instance. The default executor :class:`concurrent.futures.ThreadPoolExecutor` + is used if not set by :meth:`loop.set_default_executor`. Example:: From 29d28ffdda6b343be87850ef47ce0649cff467bd Mon Sep 17 00:00:00 2001 From: AN Long Date: Thu, 4 Jul 2024 13:30:06 +0800 Subject: [PATCH 3/4] Remove trailing whitespace --- Doc/library/asyncio-eventloop.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 4ea72e4baf98d5..197156878e6361 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1261,7 +1261,7 @@ Executing code in thread or process pools Arrange for *func* to be called in the specified executor. The *executor* argument should be a :class:`concurrent.futures.Executor` - instance. The default executor :class:`concurrent.futures.ThreadPoolExecutor` + instance. The default executor :class:`concurrent.futures.ThreadPoolExecutor` is used if not set by :meth:`loop.set_default_executor`. Example:: From fc39a8119fa7d52ab75384b180a0fb2b5979cdf9 Mon Sep 17 00:00:00 2001 From: AN Long Date: Mon, 8 Jul 2024 20:43:44 +0800 Subject: [PATCH 4/4] Update document --- Doc/library/asyncio-eventloop.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 197156878e6361..70bdd154d6c406 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1260,9 +1260,11 @@ Executing code in thread or process pools Arrange for *func* to be called in the specified executor. - The *executor* argument should be a :class:`concurrent.futures.Executor` - instance. The default executor :class:`concurrent.futures.ThreadPoolExecutor` - is used if not set by :meth:`loop.set_default_executor`. + The *executor* argument should be an :class:`concurrent.futures.Executor` + instance. The default executor is used if *executor* is ``None``. + The default executor can be set by :meth:`loop.set_default_executor`, + otherwise, a :class:`concurrent.futures.ThreadPoolExecutor` will be + lazy-initialized and used by :func:`run_in_executor` if needed. Example::