summaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/utils/sysinfo.py
diff options
context:
space:
mode:
authorrobot-contrib <[email protected]>2022-05-18 00:43:36 +0300
committerrobot-contrib <[email protected]>2022-05-18 00:43:36 +0300
commit9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch)
tree78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/utils/sysinfo.py
parent8113a823ffca6451bb5ff8f0334560885a939a24 (diff)
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/utils/sysinfo.py')
-rw-r--r--contrib/python/ipython/py3/IPython/utils/sysinfo.py66
1 files changed, 21 insertions, 45 deletions
diff --git a/contrib/python/ipython/py3/IPython/utils/sysinfo.py b/contrib/python/ipython/py3/IPython/utils/sysinfo.py
index 07d14fd8a48..857f0cf2d84 100644
--- a/contrib/python/ipython/py3/IPython/utils/sysinfo.py
+++ b/contrib/python/ipython/py3/IPython/utils/sysinfo.py
@@ -40,15 +40,15 @@ def pkg_commit_hash(pkg_path):
Parameters
----------
pkg_path : str
- directory containing package
- only used for getting commit from active repo
+ directory containing package
+ only used for getting commit from active repo
Returns
-------
hash_from : str
- Where we got the hash from - description
+ Where we got the hash from - description
hash_str : str
- short form of hash
+ short form of hash
"""
# Try and get commit from written commit text file
if _sysinfo.commit:
@@ -71,12 +71,12 @@ def pkg_info(pkg_path):
Parameters
----------
pkg_path : str
- path containing __init__.py for package
+ path containing __init__.py for package
Returns
-------
context : dict
- with named parameters of interest
+ with named parameters of interest
"""
src, hsh = pkg_commit_hash(pkg_path)
return dict(
@@ -118,49 +118,25 @@ def sys_info():
"""
return pprint.pformat(get_sys_info())
-def _num_cpus_unix():
- """Return the number of active CPUs on a Unix system."""
- return os.sysconf("SC_NPROCESSORS_ONLN")
-
-
-def _num_cpus_darwin():
- """Return the number of active CPUs on a Darwin system."""
- p = subprocess.Popen(['sysctl','-n','hw.ncpu'],stdout=subprocess.PIPE)
- return p.stdout.read()
-
-
-def _num_cpus_windows():
- """Return the number of active CPUs on a Windows system."""
- return os.environ.get("NUMBER_OF_PROCESSORS")
-
def num_cpus():
- """Return the effective number of CPUs in the system as an integer.
-
- This cross-platform function makes an attempt at finding the total number of
- available CPUs in the system, as returned by various underlying system and
- python calls.
+ """DEPRECATED
- If it can't find a sensible answer, it returns 1 (though an error *may* make
- it return a large positive number that's actually incorrect).
- """
+ Return the effective number of CPUs in the system as an integer.
- # Many thanks to the Parallel Python project (http://www.parallelpython.com)
- # for the names of the keys we needed to look up for this function. This
- # code was inspired by their equivalent function.
+ This cross-platform function makes an attempt at finding the total number of
+ available CPUs in the system, as returned by various underlying system and
+ python calls.
- ncpufuncs = {'Linux':_num_cpus_unix,
- 'Darwin':_num_cpus_darwin,
- 'Windows':_num_cpus_windows
- }
-
- ncpufunc = ncpufuncs.get(platform.system(),
- # default to unix version (Solaris, AIX, etc)
- _num_cpus_unix)
+ If it can't find a sensible answer, it returns 1 (though an error *may* make
+ it return a large positive number that's actually incorrect).
+ """
+ import warnings
- try:
- ncpus = max(1,int(ncpufunc()))
- except:
- ncpus = 1
- return ncpus
+ warnings.warn(
+ "`num_cpus` is deprecated since IPython 8.0. Use `os.cpu_count` instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return os.cpu_count() or 1