mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #550
This commit is contained in:
parent
2c80dbda83
commit
0aa53a163a
@ -257,7 +257,16 @@ def detect_ncpus():
|
|||||||
return ncpus
|
return ncpus
|
||||||
else:
|
else:
|
||||||
#MacOS X
|
#MacOS X
|
||||||
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
|
try:
|
||||||
|
return int(subprocess.Popen(('sysctl', '-n', 'hw.cpu'), stdout=subprocess.PIPE).stdout.read())
|
||||||
|
except IOError: # Occassionally the system call gets interrupted
|
||||||
|
try:
|
||||||
|
return int(subprocess.Popen(('sysctl', '-n', 'hw.cpu'), stdout=subprocess.PIPE).stdout.read())
|
||||||
|
except IOError:
|
||||||
|
return 1
|
||||||
|
except ValueError: # On some systems the sysctl call fails
|
||||||
|
return 1
|
||||||
|
|
||||||
#for Windows
|
#for Windows
|
||||||
if os.environ.has_key("NUMBER_OF_PROCESSORS"):
|
if os.environ.has_key("NUMBER_OF_PROCESSORS"):
|
||||||
ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
|
ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user