Visitar URL original
bpo-29595: Expose max_queue_size in ThreadPoolExecutor by prayerslayer 路 Pull Request #143 路 python/cpython 路 GitHub
Skip to content
Closed
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
Prev Previous commit
Next Next commit
update docs
  • Loading branch information
prayerslayer authored Feb 20, 2017
commit 6103533b364c19c48f5d61eb1dbef8cfc71c9727
11 changes: 9 additions & 2 deletions Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ And::
executor.submit(wait_on_future)


.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='')
.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', max_queue_size=0)

An :class:`Executor` subclass that uses a pool of at most *max_workers*
threads to execute calls asynchronously.
threads to execute calls asynchronously. If all worker threads are busy it
buffers new work items using a queue of maximum size *max_queue_size*.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please document that map and submit will block if the queue size is reached.


.. versionchanged:: 3.5
If *max_workers* is ``None`` or
Expand All @@ -141,6 +142,12 @@ And::
The *thread_name_prefix* argument was added to allow users to
control the threading.Thread names for worker threads created by
the pool for easier debugging.

.. versionadded:: 3.7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For a new function parameter, this should be versionchanged (versionadded means the function itself is new). Unfortunately, it seems we did the same mistake above for thread_name_prefix...

The *max_queue_size* argument was added to allow users to control
the maximum queue size to not accidentally run out of memory when
new work items are added at a higher rate than what the worker
threads can handle.

.. _threadpoolexecutor-example:

Expand Down