Avoid using PyQt to detect the number of CPUs on windows

This commit is contained in:
Kovid Goyal 2014-07-12 18:08:55 +05:30
parent 12882d2a99
commit 6a5acd3fe7

View File

@ -471,16 +471,18 @@ class CurrentDir(object):
def detect_ncpus(): def detect_ncpus():
"""Detects the number of effective CPUs in the system""" """Detects the number of effective CPUs in the system"""
import multiprocessing if iswindows:
ans = -1 import win32api
try: ans = win32api.GetSystemInfo()[5]
ans = multiprocessing.cpu_count() else:
except: import multiprocessing
from PyQt5.Qt import QThread ans = -1
ans = QThread.idealThreadCount() try:
if ans < 1: ans = multiprocessing.cpu_count()
ans = 1 except Exception:
return ans from PyQt5.Qt import QThread
ans = QThread.idealThreadCount()
return max(1, ans)
relpath = os.path.relpath relpath = os.path.relpath