diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-06-12 14:58:57 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-06-18 08:49:10 +0000 |
commit | 2e9fcce77520644ad08eda84badc48c07879ce11 (patch) | |
tree | 592fe8e7ad9861ed6e7de7ae490405dfef29d70c | |
parent | 0a83e87c9dd2cd250ff157fa0e4283fee2f47c26 (diff) | |
download | buildstream-aevri/psutil_affinity.tar.gz |
_platform.get_cpu_count: use psutil instead of osaevri/psutil_affinity
Be Windows-friendly by using the portable
`psutil.Process().cpu_affinity()` instead of `os.sched_getaffinity`.
Note that unfortunately this still doesn't work on Mac, so we keep that
platform-specific override.
-rw-r--r-- | src/buildstream/_platform/platform.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index dba60ddca..0fbe145f9 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py @@ -22,6 +22,8 @@ import platform import sys import resource +import psutil + from .._exceptions import PlatformError, ImplError @@ -68,7 +70,7 @@ class Platform(): return cls._instance def get_cpu_count(self, cap=None): - cpu_count = len(os.sched_getaffinity(0)) + cpu_count = len(psutil.Process().cpu_affinity()) if cap is None: return cpu_count else: |