8000 gh-124694: Document missing ctxkwargs argument in ThreadPoolExecutor by donBarbos · Pull Request #134321 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-124694: Document missing ctxkwargs argument in ThreadPoolExecutor #134321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-124694: Document missing ctxkwargs argument in ThreadPoolExecutor
  • Loading branch information
donBarbos committed May 20, 2025
commit 837ead9205fb786e7fd170266a8c7986ec10bf31
28 changes: 18 additions & 10 deletions Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ Executor Objects
:class:`ThreadPoolExecutor` and :class:`InterpreterPoolExecutor`,
*chunksize* has no effect.

.. versionchanged:: 3.5
.. versionadded:: 3.5
Added the *chunksize* parameter.

.. versionchanged:: 3.14
.. versionadded:: 3.14
Added the *buffersize* parameter.

.. method:: shutdown(wait=True, *, cancel_futures=False)
Expand Down Expand Up @@ -113,7 +113,7 @@ Executor Objects
e.submit(shutil.copy, 'src3.txt', 'dest3.txt')
e.submit(shutil.copy, 'src4.txt', 'dest4.txt')

.. versionchanged:: 3.9
.. versionadded:: 3.9
Added *cancel_futures*.


Expand Down Expand Up @@ -154,7 +154,8 @@ And::
executor.submit(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.
Expand All @@ -180,12 +181,12 @@ And::
should be higher than the number of workers
for :class:`ProcessPoolExecutor`.

.. versionchanged:: 3.6
.. versionadded:: 3.6
Added the *thread_name_prefix* parameter to allow users to
control the :class:`threading.Thread` names for worker threads created by
the pool for easier debugging.

.. versionchanged:: 3.7
.. versionadded:: 3.7
Added the *initializer* and *initargs* arguments.

.. versionchanged:: 3.8
Expand All @@ -201,6 +202,10 @@ And::
Default value of *max_workers* is changed to
``min(32, (os.process_cpu_count() or 1) + 4)``.

.. versionadded:: 3.14
Added *ctxkwargs* to pass additional arguments to ``cls.prepare_context``
class method.


.. _threadpoolexecutor-example:

Expand Down Expand Up @@ -287,7 +292,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=(), shared=None)
.. class:: InterpreterPoolExecutor(max_workers=None, thread_name_prefix='', \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated, but it's probably an improvement as it's now more readable. So I'm ok with it.

initializer=None, initargs=(), shared=None)

A :class:`ThreadPoolExecutor` subclass that executes calls asynchronously
using a pool of at most *max_workers* threads. Each thread runs
Expand Down Expand Up @@ -357,7 +363,9 @@ that :class:`ProcessPoolExecutor` will not work in the interactive interpreter.
Calling :class:`Executor` or :class:`Future` methods from a callable submitted
to a :class:`ProcessPoolExecutor` will result in deadlock.

.. 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
Expand Down Expand Up @@ -394,13 +402,13 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
was undefined but operations on the executor or its futures would often
freeze or deadlock.

.. versionchanged:: 3.7
.. versionadded:: 3.7
The *mp_context* argument was added to allow users to control the
start_method for worker processes created by the pool.

Added the *initializer* and *initargs* arguments.

.. versionchanged:: 3.11
.. versionadded:: 3.11
The *max_tasks_per_child* argument was added to allow users to
control the lifetime of workers in the pool.

Expand Down
Loading
0