Use psutil.cpu_count(logical=False) in auto_detect_cpus()

This commit is contained in:
Ivan Zaikin
2020-07-23 10:18:43 +07:00
parent 2fc21fddbb
commit 77e5fdfef9
3 changed files with 10 additions and 30 deletions

View File

@@ -1,28 +1,13 @@
import os
import uuid
import psutil
import py
import pytest
def auto_detect_cpus():
try:
from os import sched_getaffinity
except ImportError:
if os.environ.get("TRAVIS") == "true":
# workaround https://bitbucket.org/pypy/pypy/issues/2375
return 2
try:
from os import cpu_count
except ImportError:
from multiprocessing import cpu_count
else:
def cpu_count():
return len(sched_getaffinity(0))
try:
n = cpu_count()
n = psutil.cpu_count(logical=False)
except NotImplementedError:
return 1
return n if n else 1