diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst index 5a950081a1c98d..693d1356946e5e 100644 --- a/Doc/library/concurrent.futures.rst +++ b/Doc/library/concurrent.futures.rst @@ -415,6 +415,19 @@ to a :class:`ProcessPoolExecutor` will result in deadlock. require the *fork* start method for :class:`ProcessPoolExecutor` you must explicitly pass ``mp_context=multiprocessing.get_context("fork")``. + .. method:: terminate_workers(signal=signal.SIGTERM) + + Attempt to terminate all living worker processes immediately by sending each + of them the given signal. If the signal is not specified, the default signal + :data:`signal.SIGTERM` is used. + + After calling :meth:`ProcessPoolExecutor.terminate_workers`, the caller, should + no longer submit tasks to the executor. It is also recommended to still call + :meth:`ProcessPoolExecutor.shutdown` to ensure that all other resources + associated with the executor are freed. + + .. versionadded:: 3.14 + .. _processpoolexecutor-example: ProcessPoolExecutor Example diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index d13cd2d5173a04..54d7909c94482e 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -306,6 +306,9 @@ concurrent.futures incompatible *fork* start method you must explicitly request it by supplying a *mp_context* to :class:`concurrent.futures.ProcessPoolExecutor`. (Contributed by Gregory P. Smith in :gh:`84559`.) +* Add :meth:`concurrent.futures.ProcessPoolExecutor.terminate_workers` as + a way to terminate all living worker processes in the given pool. + (Contributed by Charles Machalow in :gh:`128043`.) ctypes ------