diff options
author | Kyle Stanley <aeros167@gmail.com> | 2020-02-02 12:49:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-02 12:49:00 (GMT) |
commit | 339fd46cb764277cbbdc3e78dcc5b45b156bb6ae (patch) | |
tree | 2366d3abf217d3017a50e2b024d67be731a49347 /Doc | |
parent | be8147bdc6111a225ec284a4514277304726c3d0 (diff) | |
download | cpython-339fd46cb764277cbbdc3e78dcc5b45b156bb6ae.zip cpython-339fd46cb764277cbbdc3e78dcc5b45b156bb6ae.tar.gz cpython-339fd46cb764277cbbdc3e78dcc5b45b156bb6ae.tar.bz2 |
bpo-39349: Add *cancel_futures* to Executor.shutdown() (GH-18057)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/concurrent.futures.rst | 14 | ||||
-rw-r--r-- | Doc/whatsnew/3.9.rst | 9 |
2 files changed, 22 insertions, 1 deletions
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 @@ 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 ------------------ diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index ee37b5a..931f8bf 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -146,6 +146,15 @@ that schedules a shutdown for the default executor that waits on the Added :class:`asyncio.PidfdChildWatcher`, a Linux-specific child watcher implementation that polls process file descriptors. (:issue:`38692`) +concurrent.futures +------------------ + +Added a new *cancel_futures* parameter to +:meth:`concurrent.futures.Executor.shutdown` that cancels all pending futures +which have not started running, instead of waiting for them to complete before +shutting down the executor. +(Contributed by Kyle Stanley in :issue:`39349`.) + curses ------ |