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

Use os.sched_getaffinity for cpu counts when available #2979

Merged
merged 1 commit into from Aug 30, 2023

Conversation

jdb8
Copy link
Contributor

@jdb8 jdb8 commented Aug 29, 2023

Attempt at fixing/improving #2978 for systems that support the os.sched_getaffinity method.

When unavailable (i.e. on mac), we fall back to the old behaviour.

I didn't know how much to mess with the existing tests so went with a new fixture to simulate when this is unavailable - I don't have a windows machine to test on so let me know if there's a better way to avoid this change being annoying!

resolves #2978

tests/lang_base_test.py Outdated Show resolved Hide resolved
@asottile
Copy link
Member

pre-commit.ci run

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit ac42dc5 into pre-commit:main Aug 30, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

CPU count logic does not distinguish "usable" CPUs inside cgroup'd containers (e.g. inside k8s)
2 participants