]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-39349: Add cancel_futures to Executor.shutdown base class (GH-22023) (GH...
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>
Wed, 2 Sep 2020 19:28:28 +0000 (12:28 -0700)
committerGitHub <noreply@github.com>
Wed, 2 Sep 2020 19:28:28 +0000 (15:28 -0400)
* Add cancel_futures parameter to the Executor base class, since it was missed in the original PR (https://github.com/python/cpython/pull/18057) that added cancel_futures.
(cherry picked from commit 17dc1b7)

Lib/concurrent/futures/_base.py

index bf546f8ae1d1cc92f346f6de0842108e178f70a1..00eb54881f2958d23dadcf0fadb2af552de57161 100644 (file)
@@ -605,7 +605,7 @@ class Executor(object):
                     future.cancel()
         return result_iterator()
 
-    def shutdown(self, wait=True):
+    def shutdown(self, wait=True, *, cancel_futures=False):
         """Clean-up the resources associated with the Executor.
 
         It is safe to call this method several times. Otherwise, no other
@@ -615,6 +615,9 @@ class Executor(object):
             wait: If True then shutdown will not return until all running
                 futures have finished executing and the resources used by the
                 executor have been reclaimed.
+            cancel_futures: If True then shutdown will cancel all pending
+                futures. Futures that are completed or running will not be
+                cancelled.
         """
         pass