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.

Author neologix
Recipients Yogesh.Chaudhari, dilettant, ezio.melotti, kushal.das, nedbat, neologix, pitrou, r.david.murray, serhiy.storchaka, trent, vstinner
Date 2013-05-13.05:52:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
> 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()

Do we really need cpu_count() in three places with different semantics?
Also, it doesn't belong to shutil(), which stands for shell utilities IIRC.

IMO just one version in Modules/posixmodule.c is enough (with
multiprocessing's version as an alias), there's no need to
over-engineer this.
It can return None, that's fine with me now at this point.

> 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.

Well, HP-UX isn't officially supported, so that's reasonable.

> 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.

That's reasonable.
Date User Action Args
2013-05-13 05:52:06neologixsetrecipients: + neologix, pitrou, vstinner, nedbat, trent, ezio.melotti, r.david.murray, serhiy.storchaka, kushal.das, dilettant, Yogesh.Chaudhari
2013-05-13 05:52:06neologixlinkissue17914 messages
2013-05-13 05:52:06neologixcreate