Message189076
Here is a new patch (cpu_count.patch) with a different approach:
* add a os.cpu_count() which returns the raw value (may be zero or negative if the OS returns a dummy value) and raise an OSError on error
* os.cpu_count() is not available on all platforms
* shutil.cpu_count() is the high level API using 1 as a fallback. The fallback value (which is 1 by default) is configurable, ex: shutil.cpu_count(fallback=None) returns None on os.cpu_count() error.
* multiprocessing.cpu_count() simply reuses shutil.cpu_count()
So os.cpu_count() as a well defined behaviour, and shutil.cpu_count() is the convinient API.
My patch is based on issue17914-4.patch and so also on Trent Nelson's code.
I only tested my patch on Linux. It must be tested on other platforms. If nobody tests the patch on HPUX, it would be safer to remove HPUX support.
It looks like Trent's code was not tested, I don't think that his code works on platforms other than Windows.
test_os will fail if os.cpu_count() fails. The test should be fixed to handle failures, but I prefer to start with a failing test to check if the error case occurs on a buildbot. |
|
Date |
User |
Action |
Args |
2013-05-12 23:56:12 | vstinner | set | recipients:
+ vstinner, pitrou, nedbat, trent, ezio.melotti, r.david.murray, neologix, serhiy.storchaka, kushal.das, dilettant, Yogesh.Chaudhari |
2013-05-12 23:56:12 | vstinner | set | messageid: <1368402972.0.0.444255584628.issue17914@psf.upfronthosting.co.za> |
2013-05-12 23:56:11 | vstinner | link | issue17914 messages |
2013-05-12 23:56:11 | vstinner | create | |
|