Issue21527
Created on 2014-05-18 22:47 by Claudiu.Popa, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| concurrent_futures_workers.patch | Claudiu.Popa, 2014-05-18 22:47 | review | ||
| issue21527.patch | Claudiu.Popa, 2014-08-28 08:56 | Update max_workers | review | |
| Messages (5) | |||
|---|---|---|---|
| msg218763 - (view) | Author: PCManticore (Claudiu.Popa) * | Date: 2014-05-18 22:47 | |
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.
|
|||
| msg218840 - (view) | Author: Josh Rosenberg (josh.r) * | Date: 2014-05-20 10:29 | |
+1. Makes it easier to swap Executors (which is a big selling point for the Executor framework), and number of cores is a reasonable default value. |
|||
| msg226032 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2014-08-28 16:57 | |
Looks good. |
|||
| msg226212 - (view) | Author: PCManticore (Claudiu.Popa) * | Date: 2014-09-01 06:45 | |
Thank you, Guido. |
|||
| msg226278 - (view) | Author: Roundup Robot (python-dev) | Date: 2014-09-02 17:39 | |
New changeset 2805b0dca798 by Guido van Rossum in branch 'default': Closes #21527: Add default number of workers to ThreadPoolExecutor. (Claudiu Popa.) http://hg.python.org/cpython/rev/2805b0dca798 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:03 | admin | set | github: 65726 |
| 2014-09-02 17:39:27 | python-dev | set | status: open -> closed nosy:
+ python-dev resolution: fixed |
| 2014-09-01 06:45:04 | Claudiu.Popa | set | messages:
+ msg226212 stage: patch review -> commit review |
| 2014-08-28 16:57:38 | gvanrossum | set | nosy:
+ gvanrossum messages: + msg226032 |
| 2014-08-28 08:56:24 | Claudiu.Popa | set | files: + issue21527.patch |
| 2014-06-22 05:49:55 | Claudiu.Popa | set | stage: patch review |
| 2014-05-20 10:29:19 | josh.r | set | nosy:
+ josh.r messages: + msg218840 |
| 2014-05-18 22:47:47 | Claudiu.Popa | create | |