This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: concurrent.futures: cannot specify the number of cores
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Python++, asvetlov, pablogsal, terry.reedy, vstinner, yselivanov
Priority: normal Keywords:

Created on 2018-06-10 18:05 by Python++, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
BUG for concurrent.futures(Found by william).py Python++, 2018-06-10 18:11 Code for A BUG in concurrent/asyncio
Messages (6)
msg319229 - (view) Author: Python++ (Python++) Date: 2018-06-10 18:05
ProcessPoolExecutor cannot specify the number of cores when running the Muti-Sub Event Loops, which results in the resulting statistics of the last code run cannot be promised to be separated.

I'm deep hoping some genius can propose a solution and fix these problems.
msg319231 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-10 18:18
> which results in the resulting statistics of the last code run cannot be promised to be separated.

I'm sorry but I cannot parse your message and the attached code snippet. Please try to formulate the actual bug/feature request more clearly.
msg319277 - (view) Author: Python++ (Python++) Date: 2018-06-11 07:09
First Kind of resutl sets:

=====================================================

Process-2:<4816> is ProcessExecuting [0]
MainThread:<4816> is ThreadExecuting [0]
exe_iter:0 sub_iter:0
Run for Wheel and result:0
callback number:1
MainThread:<4816> is ThreadExecuting [1]
exe_iter:0 sub_iter:1
Run for Wheel and result:2
callback number:2
Process-1:<4512> is ProcessExecuting [1]
MainThread:<4512> is ThreadExecuting [0]
exe_iter:1 sub_iter:0
Run for Wheel and result:0
callback number:1
MainThread:<4512> is ThreadExecuting [1]
exe_iter:1 sub_iter:1
Run for Wheel and result:2
callback number:2
======================================================
Program runs with different Threads:
Tread ID: 4816 and 4512
callback numbers are 1, 2; 1, 2
====================================================

Second Kind of resutl sets:

======================================================
Process-1:<7360> is ProcessExecuting [0]
MainThread:<7360> is ThreadExecuting [0]
exe_iter:0 sub_iter:0
Run for Wheel and result:0
callback number:1
MainThread:<7360> is ThreadExecuting [1]
exe_iter:0 sub_iter:1
Run for Wheel and result:2
callback number:2
Process-1:<7360> is ProcessExecuting [1]
MainThread:<7360> is ThreadExecuting [0]
exe_iter:1 sub_iter:0
Run for Wheel and result:0
callback number:3
MainThread:<7360> is ThreadExecuting [1]
exe_iter:1 sub_iter:1
Run for Wheel and result:2
callback number:4
=================================================

Program runs with the same and only Thread:
Tread ID: 7360
callback numbers are 1, 2; 3, 4

Based on the above situation, it is impossible to ensure that multiple
processes will run the program all the way by employing Process Pool.

2018-06-11 2:18 GMT+08:00 Yury Selivanov <report@bugs.python.org>:

>
> Yury Selivanov <yselivanov@gmail.com> added the comment:
>
> > which results in the resulting statistics of the last code run cannot be
> promised to be separated.
>
> I'm sorry but I cannot parse your message and the attached code snippet.
> Please try to formulate the actual bug/feature request more clearly.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue33823>
> _______________________________________
>
msg319527 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-06-14 16:01
Python++: Sorry, I still cannot understand exactly what is wrong. Could you please redact a little paragraph explaining (1) what function/functions are you using (and maybe a very short example), (2) what is not working and (3) what do you expect to see instead. Sorry if it feels redundant but it will help is understand better the problem.
msg319628 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-15 17:38
Python++, when you respond by email, rather than on the web form, delete the message you are responding to.  It is already present on the web page and should not be repeated.

I unlinked msg319278 because it uselessly repeats the same message that it responds to.
msg320585 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-27 14:30
The first argument of ProcessPoolExecutor is the maximum number of workers. You can use os.cpu_count() to get the number of CPU cores.

https://docs.python.org/dev/library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor

I don't see anything wrong here, I close the issue.
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78004
2018-06-27 14:30:08vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg320585

resolution: not a bug
stage: resolved
2018-06-27 14:28:46vstinnersetcomponents: + Library (Lib), - asyncio
title: A BUG in concurrent/asyncio -> concurrent.futures: cannot specify the number of cores
2018-06-15 17:38:44terry.reedysetnosy: + terry.reedy
messages: + msg319628
2018-06-15 17:35:21terry.reedysetmessages: - msg319278
2018-06-14 16:01:56pablogsalsetnosy: + pablogsal
messages: + msg319527
2018-06-11 07:12:04Python++setmessages: + msg319278
2018-06-11 07:09:43Python++setmessages: + msg319277
2018-06-10 18:18:08yselivanovsetmessages: + msg319231
2018-06-10 18:11:00Python++setfiles: + BUG for concurrent.futures(Found by william).py
2018-06-10 18:05:17Python++create