diff options
author | Kyle Stanley <aeros167@gmail.com> | 2020-02-02 07:49:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-02 13:49:00 +0100 |
commit | 339fd46cb764277cbbdc3e78dcc5b45b156bb6ae (patch) | |
tree | 2366d3abf217d3017a50e2b024d67be731a49347 /Doc/library | |
parent | be8147bdc6111a225ec284a4514277304726c3d0 (diff) | |
download | cpython-git-339fd46cb764277cbbdc3e78dcc5b45b156bb6ae.tar.gz |
bpo-39349: Add *cancel_futures* to Executor.shutdown() (GH-18057)
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/concurrent.futures.rst | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst index d71f2d80c9..b21d5594c8 100644 --- a/Doc/library/concurrent.futures.rst +++ b/Doc/library/concurrent.futures.rst @@ -67,7 +67,7 @@ Executor Objects .. 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 @@ Executor Objects 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 @@ Executor Objects e.submit(shutil.copy, 'src3.txt', 'dest3.txt') e.submit(shutil.copy, 'src4.txt', 'dest4.txt') + .. versionchanged:: 3.9 + Added *cancel_futures*. + ThreadPoolExecutor ------------------ |