Reasons to deprecate it
=======================
- it's calculated at import time, also unnecessarily if the user does not use
it later
- import time is risky: if the retrieval fails for some reason the whole
program will explode (see for example issue 188). Right now we alleviate the
problem by catching the exception and produce a warning but it's sub optimal.
Replacement
===========
- a new psutil.cpu_count() can be introduced
- that will also be consistent with os.cpu_count() introduced in python 3.4
http://docs.python.org/3.4/library/os.html#os.cpu_count
- it paves the way for upcoming psutil.phys_cpu_count() (see issue 427)
Deprecation process
===================
Deprecation of a module level constant is harder than deprecating a function
because it's more tricky:
http://stackoverflow.com/questions/9937279/can-modules-have-properties
http://stackoverflow.com/questions/880530/can-python-modules-have-properties-the
-same-way-that-objects-can
I expect to introduce the "module property" hack in some next version (say
1.3.0) which will produce a DeprecationWarning and remove it completely in a
major one (say 2.0.0) along with others already deprecated APIs such as
psutil.BOOT_TIME.
Original issue reported on code.google.com by g.rodola on 3 Dec 2013 at 6:08
Original issue reported on code.google.com by
g.rodola
on 3 Dec 2013 at 6:08