mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
py3: Use os.cpu_count()
This commit is contained in:
parent
e574e47b71
commit
01326d69cf
@ -18,7 +18,7 @@ except EnvironmentError:
|
||||
|
||||
from calibre.constants import (iswindows, isosx, islinux, isfrozen,
|
||||
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
||||
win32event, win32api, winerror, fcntl,
|
||||
win32event, win32api, winerror, fcntl, ispy3,
|
||||
filesystem_encoding, plugins, config_dir)
|
||||
from calibre.startup import winutil, winutilerror
|
||||
from calibre.utils.icu import safe_chr
|
||||
@ -454,7 +454,14 @@ class CurrentDir(object):
|
||||
_ncpus = None
|
||||
|
||||
|
||||
def detect_ncpus():
|
||||
if ispy3:
|
||||
def detect_ncpus():
|
||||
global _ncpus
|
||||
if _ncpus is None:
|
||||
_ncpus = max(1, os.cpu_count() or 1)
|
||||
return _ncpus
|
||||
else:
|
||||
def detect_ncpus():
|
||||
"""Detects the number of effective CPUs in the system"""
|
||||
global _ncpus
|
||||
if _ncpus is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user