Refactored getting cores count to be work cross platform.
This commit is contained in:
parent
3eb460dcf6
commit
b4c198b0ef
1 changed files with 6 additions and 6 deletions
|
|
@ -19,6 +19,7 @@
|
|||
from gi.repository import GObject
|
||||
import os
|
||||
import pkg_resources
|
||||
import platform
|
||||
|
||||
|
||||
class configuration(GObject.GObject):
|
||||
|
|
@ -49,12 +50,11 @@ class configuration(GObject.GObject):
|
|||
return config_folder
|
||||
|
||||
def _fill_config(self):
|
||||
self.cores = 0
|
||||
proc_file = open("/proc/cpuinfo", "r")
|
||||
for line in proc_file:
|
||||
if (line.startswith("processor")):
|
||||
self.cores += 1
|
||||
proc_file.close()
|
||||
self.cores = os.cpu_count()
|
||||
if 'sched_getaffinity' in dir(os):
|
||||
self.cores = len(os.sched_getaffinity(0))
|
||||
if platform.system() == 'FreeBSD':
|
||||
self.cores = int(os.popen("sysctl -n kern.smp.cores").read().split('\n')[0])
|
||||
|
||||
is_local = None
|
||||
self.log = ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue