From b89e0ce508a9aa104e1a33e127c63ffe738d8229 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Jun 2009 10:56:02 -0700 Subject: [PATCH] Fix CPU detection on OS X --- src/calibre/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 2bbf18d9e0..d7c5f0b223 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -277,7 +277,16 @@ class StreamReadWrapper(object): def detect_ncpus(): """Detects the number of effective CPUs in the system""" - return multiprocessing.cpu_count() + ans = -1 + try: + ans = multiprocessing.cpu_count() + except: + from PyQt4.Qt import QThread + ans = QThread.idealThreadCount() + if ans < 1: + ans = 1 + return ans + def launch(path_or_url): if os.path.exists(path_or_url):