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

Fix crash when cpu_count() is called with logical=False. #1471

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

peeterm007
Copy link
Contributor

  • Add cpu_count_cores() to list of symbols in _psutil_bsd.c.

Before:

import psutil
psutil.cpu_count()
8
psutil.cpu_count(logical=True)
8
psutil.cpu_count(logical=False)
Traceback (most recent call last):
File "", line 1, in File "/usr/local/lib/python3.9/site-packages/psutil/init.py", line 1591, in cpu_count ret = _psplatform.cpu_count_cores() File "/usr/local/lib/python3.9/site-packages/psutil/_psbsd.py", line 286, in cpu_count_cores return cext.cpu_count_cores() AttributeError: module 'psutil._psutil_bsd' has no attribute 'cpu_count_cores'

After:

import psutil
psutil.cpu_count()
8
psutil.cpu_count(logical=True)
8
psutil.cpu_count(logical=False)
4

* Add cpu_count_cores() to list of symbols in _psutil_bsd.c.

Before:

>>> import psutil
>>> psutil.cpu_count()
8
>>> psutil.cpu_count(logical=True)
8
>>> psutil.cpu_count(logical=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/psutil/__init__.py", line 1591, in cpu_count
    ret = _psplatform.cpu_count_cores()
  File "/usr/local/lib/python3.9/site-packages/psutil/_psbsd.py", line 286, in cpu_count_cores
    return cext.cpu_count_cores()
AttributeError: module 'psutil._psutil_bsd' has no attribute 'cpu_count_cores'
>>>

After:

>>> import psutil
>>> psutil.cpu_count()
8
>>> psutil.cpu_count(logical=True)
8
>>> psutil.cpu_count(logical=False)
4
>>>
@tuxillo tuxillo merged commit 850c096 into DragonFlyBSD:master Mar 28, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants