https://github.com/python/cpython/commit/be986a6a1cd9d33faddbb9c3c22eaef6f409930f
commit: be986a6a1cd9d33faddbb9c3c22eaef6f409930f
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: ambv <[email protected]>
date: 2026-10-23T11:37:10-07:00
summary:

[3.14] gh-124694: Document missing ctxkwargs argument in ThreadPoolExecutor 
(GH-134321) (GH-160460)

(cherry picked from commit 9a4187a69765ccba4553f576af7ec80cb5bbae70)

Co-authored-by: Semyon Moroz <[email protected]>

files:
M Doc/library/concurrent.futures.rst

diff --git a/Doc/library/concurrent.futures.rst 
b/Doc/library/concurrent.futures.rst
index 6f0c039d34b612..139988c1e17297 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -119,7 +119,7 @@ Executor Objects
              e.submit(shutil.copy, 'src4.txt', 'dest4.txt')
 
       .. versionchanged:: 3.9
-         Added *cancel_futures*.
+         Added the *cancel_futures* parameter.
 
 
 ThreadPoolExecutor
@@ -161,7 +161,8 @@ And::
    # the single worker thread is already waiting for wait_on_future().
 
 
-.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', 
initializer=None, initargs=())
+.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', \
+                              initializer=None, initargs=(), **ctxkwargs)
 
    An :class:`Executor` subclass that uses a pool of at most *max_workers*
    threads to execute calls asynchronously.
@@ -179,6 +180,18 @@ And::
    pending jobs will raise a 
:exc:`~concurrent.futures.thread.BrokenThreadPool`,
    as well as any attempt to submit more jobs to the pool.
 
+   *ctxkwargs* is a mapping of additional keyword arguments passed to
+   :meth:`prepare_context`, allowing customization of the worker execution
+   context.
+
+   .. classmethod:: prepare_context(initializer, initargs)
+
+      Setting up the necessary context for creating worker instances in a
+      pool-based executor (for example, in a concurrent environment like
+      threads or interpreters).
+
+      .. versionadded:: 3.14
+
    .. versionchanged:: 3.5
       If *max_workers* is ``None`` or
       not given, it will default to the number of processors on the machine,
@@ -208,6 +221,10 @@ And::
       Default value of *max_workers* is changed to
       ``min(32, (os.process_cpu_count() or 1) + 4)``.
 
+   .. versionchanged:: 3.14
+      Added *ctxkwargs* to pass additional arguments to :meth:`prepare_context`
+      class method.
+
 
 .. _threadpoolexecutor-example:
 
@@ -296,7 +313,8 @@ efficient alternative is to serialize with :mod:`pickle` 
and then send
 the bytes over a shared :mod:`socket <socket>` or
 :func:`pipe <os.pipe>`.
 
-.. class:: InterpreterPoolExecutor(max_workers=None, thread_name_prefix='', 
initializer=None, initargs=())
+.. class:: InterpreterPoolExecutor(max_workers=None, thread_name_prefix='', \
+                                   initializer=None, initargs=())
 
    A :class:`ThreadPoolExecutor` subclass that executes calls asynchronously
    using a pool of at most *max_workers* threads.  Each thread runs
@@ -356,7 +374,9 @@ per :class:`multiprocessing.Process` apply when using 
:meth:`~Executor.submit`
 and :meth:`~Executor.map` on a :class:`ProcessPoolExecutor`. A function defined
 in a REPL or a lambda should not be expected to work.
 
-.. class:: ProcessPoolExecutor(max_workers=None, mp_context=None, 
initializer=None, initargs=(), max_tasks_per_child=None)
+.. class:: ProcessPoolExecutor(max_workers=None, mp_context=None, \
+                               initializer=None, initargs=(), \
+                               max_tasks_per_child=None)
 
    An :class:`Executor` subclass that executes calls asynchronously using a 
pool
    of at most *max_workers* processes.  If *max_workers* is ``None`` or not

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to