mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Avoid using PyQt to detect the number of CPUs on windows
This commit is contained in:
parent
12882d2a99
commit
6a5acd3fe7
@ -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"""
|
||||||
|
if iswindows:
|
||||||
|
import win32api
|
||||||
|
ans = win32api.GetSystemInfo()[5]
|
||||||
|
else:
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
ans = -1
|
ans = -1
|
||||||
try:
|
try:
|
||||||
ans = multiprocessing.cpu_count()
|
ans = multiprocessing.cpu_count()
|
||||||
except:
|
except Exception:
|
||||||
from PyQt5.Qt import QThread
|
from PyQt5.Qt import QThread
|
||||||
ans = QThread.idealThreadCount()
|
ans = QThread.idealThreadCount()
|
||||||
if ans < 1:
|
return max(1, ans)
|
||||||
ans = 1
|
|
||||||
return ans
|
|
||||||
|
|
||||||
|
|
||||||
relpath = os.path.relpath
|
relpath = os.path.relpath
|
||||||
|
Loading…
x
Reference in New Issue
Block a user