Author Claudiu.Popa
Recipients Claudiu.Popa, bquinlan
Date 2014-05-18.22:47:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400453267.44.0.909455514702.issue21527@psf.upfronthosting.co.za>
In-reply-to
Content
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()
   else:
       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.
History
Date User Action Args
2014-05-18 22:47:47Claudiu.Popasetrecipients: + Claudiu.Popa, bquinlan
2014-05-18 22:47:47Claudiu.Popasetmessageid: <1400453267.44.0.909455514702.issue21527@psf.upfronthosting.co.za>
2014-05-18 22:47:47Claudiu.Popalinkissue21527 messages
2014-05-18 22:47:47Claudiu.Popacreate