Merge pull request #560 from utapyngo/logical-cpu-count

This commit is contained in:
Zac Hatfield-Dodds
2020-08-03 22:49:09 +10:00
committed by GitHub
4 changed files with 14 additions and 34 deletions

View File

@@ -1,31 +1,12 @@
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()
except NotImplementedError:
return 1
return n if n else 1
return psutil.cpu_count(logical=False) or psutil.cpu_count() or 1
class AutoInt(int):