From 63c57c8357993aed2f8057b77e51c67d475907c5 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Sat, 8 Mar 2025 12:36:48 +0100 Subject: [PATCH 1/2] Mention the "context manager" keyword in concurrent.futures documentation I was searching for context manager-related part part of this documentation and I couldn't find anything because the words "context manager" weren't actually used anywhere. I think this will help with discoverability of this feature. --- Doc/library/concurrent.futures.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst index dc613f2f8f00cd..fbb2f81830d443 100644 --- a/Doc/library/concurrent.futures.rst +++ b/Doc/library/concurrent.futures.rst @@ -94,10 +94,10 @@ Executor Objects executor has started running will be completed prior to this method returning. The remaining futures are cancelled. - You can avoid having to call this method explicitly if you use the - :keyword:`with` statement, which will shutdown the :class:`Executor` - (waiting as if :meth:`Executor.shutdown` were called with *wait* set to - ``True``):: + You can avoid having to call this method explicitly if you use the executor + as a :term:`context manager` via the :keyword:`with` statement, + which will shutdown the :class:`Executor` (waiting as if + :meth:`Executor.shutdown` were called with *wait* set to ``True``):: import shutil with ThreadPoolExecutor(max_workers=4) as e: From 0b2115214570148acb951df3b8a527081c61e019 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Sat, 8 Mar 2025 12:44:05 +0100 Subject: [PATCH 2/2] Improve the formatting a bit --- Doc/library/concurrent.futures.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst index fbb2f81830d443..efaeff69554fd5 100644 --- a/Doc/library/concurrent.futures.rst +++ b/Doc/library/concurrent.futures.rst @@ -95,9 +95,9 @@ Executor Objects returning. The remaining futures are cancelled. You can avoid having to call this method explicitly if you use the executor - as a :term:`context manager` via the :keyword:`with` statement, - which will shutdown the :class:`Executor` (waiting as if - :meth:`Executor.shutdown` were called with *wait* set to ``True``):: + as a :term:`context manager` via the :keyword:`with` statement, which + will shutdown the :class:`Executor` (waiting as if :meth:`Executor.shutdown` + were called with *wait* set to ``True``):: import shutil with ThreadPoolExecutor(max_workers=4) as e: