bpo-39349: Add *cancel_futures* to Executor.shutdown() (GH-18057)
diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst
index d71f2d8..b21d559 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -67,7 +67,7 @@
.. versionchanged:: 3.5
Added the *chunksize* argument.
- .. method:: shutdown(wait=True)
+ .. method:: shutdown(wait=True, \*, cancel_futures=False)
Signal the executor that it should free any resources that it is using
when the currently pending futures are done executing. Calls to
@@ -82,6 +82,15 @@
value of *wait*, the entire Python program will not exit until all
pending futures are done executing.
+ If *cancel_futures* is ``True``, this method will cancel all pending
+ futures that the executor has not started running. Any futures that
+ are completed or running won't be cancelled, regardless of the value
+ of *cancel_futures*.
+
+ If both *cancel_futures* and *wait* are ``True``, all futures that the
+ 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
@@ -94,6 +103,9 @@
e.submit(shutil.copy, 'src3.txt', 'dest3.txt')
e.submit(shutil.copy, 'src4.txt', 'dest4.txt')
+ .. versionchanged:: 3.9
+ Added *cancel_futures*.
+
ThreadPoolExecutor
------------------