parameters: ()
docstring: find the number of physical cpu cores
  
      linux logic adapted from B Sickler
  
      only works on linux and os x
docstring_summary: find the number of physical cpu cores
docstring_tokens: find the number of physical cpu cores
function: def getNodeRealCoreCount() :
      """
      find the number of physical cpu cores
  
      linux logic adapted from B Sickler
  
      only works on linux and os x
      """
  
      import platform
      if platform.system().find("Linux") > -1:
  
          cpuinfo = '/proc/cpuinfo'
          if not os.path.isfile(cpuinfo):
              raise EstException("Can't read processor information from '%s'" % (cpuinfo))
  
          physical_core_ids = set()
          cpu_cores = set()
  
          for line in open(cpuinfo):
              l_array = [item.strip() for item in line.strip().split(': ')]
              if len(l_array) < 2: continue
              cpuid = l_array[0]
              if cpuid == 'cpu cores':
                  cpu_cores.add(int(l_array[1]))
              if cpuid == 'physical id':
                  physical_core_ids.add(l_array[1])
  
          if len(physical_core_ids) == 0 :
              raise EstException("No 'physical id' key found in '%s'" % (cpuinfo))
          if len(cpu_cores) == 0 :
              raise EstException("No 'cpu cores' key found in '%s'" % (cpuinfo))
  
          return ( len(physical_core_ids) * cpu_cores.pop() )
  
      elif platform.system().find("Darwin") > -1:
          import subprocess
          cmd=['sysctl', '-n', 'hw.physicalcpu']
          proc=subprocess.Popen(cmd,shell=False,stdout=subprocess.PIPE)
          for line in proc.stdout :
              cpuCount=int(line.strip())
              break
  
          return cpuCount
      else:
          raise EstException("Can't determine total physical cores available on OS: '%s'" (platform.system()))
function_tokens: def getNodeRealCoreCount ( ) : import platform if platform . system ( ) . find ( "Linux" ) > - 1 : cpuinfo = '/proc/cpuinfo' if not os . path . isfile ( cpuinfo ) : raise EstException ( "Can't read processor information from '%s'" % ( cpuinfo ) ) physical_core_ids = set ( ) cpu_cores = set ( ) for line in open ( cpuinfo ) : l_array = [ item . strip ( ) for item in line . strip ( ) . split ( ': ' ) ] if len ( l_array ) < 2 : continue cpuid = l_array [ 0 ] if cpuid == 'cpu cores' : cpu_cores . add ( int ( l_array [ 1 ] ) ) if cpuid == 'physical id' : physical_core_ids . add ( l_array [ 1 ] ) if len ( physical_core_ids ) == 0 : raise EstException ( "No 'physical id' key found in '%s'" % ( cpuinfo ) ) if len ( cpu_cores ) == 0 : raise EstException ( "No 'cpu cores' key found in '%s'" % ( cpuinfo ) ) return ( len ( physical_core_ids ) * cpu_cores . pop ( ) ) elif platform . system ( ) . find ( "Darwin" ) > - 1 : import subprocess cmd = [ 'sysctl' , '-n' , 'hw.physicalcpu' ] proc = subprocess . Popen ( cmd , shell = False , stdout = subprocess . PIPE ) for line in proc . stdout : cpuCount = int ( line . strip ( ) ) break return cpuCount else : raise EstException ( "Can't determine total physical cores available on OS: '%s'" ( platform . system ( ) ) )