[New-bugs-announce] [issue21527] concurrent.futures.ThreadPoolExecutor does not use a default value

Claudiu.Popa report at bugs.python.org
Mon May 19 00:47:47 CEST 2014

New submission from Claudiu.Popa:

As the title says, ThreadPoolExecutor does not use a default value for max_workers parameter, as ProcessPoolExecutor does. When the user does not care about the number of workers and wants only for something to run in background, he has to write code like this:

if processes:
   executor = ProcessPoolExecutor()
elif threads:
   executor = ThreadPoolExecutor(1) # or any other value

This situation can also occur when the class is passed as a factory function:

def create_pool(executor_factory):
   if executor_factory is process pool:
       executor = executor_factory()
       executor = executor_factory(1)

This patch proposes using the number of cores as the default value for max_workers.
For instance, multiprocessing.pool.ThreadPool uses the same value.

components: Library (Lib)
files: concurrent_futures_workers.patch
keywords: patch
messages: 218763
nosy: Claudiu.Popa, bquinlan
priority: normal
severity: normal
status: open
title: concurrent.futures.ThreadPoolExecutor does not use a default value
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file35287/concurrent_futures_workers.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list