Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate psutil.NUM_CPUS and introduce cpu_count() #450

Closed
giampaolo opened this issue May 23, 2014 · 1 comment
Closed

Deprecate psutil.NUM_CPUS and introduce cpu_count() #450

giampaolo opened this issue May 23, 2014 · 1 comment

Comments

@giampaolo
Copy link
Owner

From g.rodola on December 03, 2013 19:08:28

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: http://code.google.com/p/psutil/issues/detail?id=450

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on December 03, 2013 13:38:01

Status: Duplicate
Mergedinto: 451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant