parameters: ()
return_statement: return 1
docstring: Detects the number of CPUs on a system.
  
      Cribbed from pp.
docstring_summary: Detects the number of CPUs on a system.
docstring_tokens: Detects the number of CPUs on a system .
function: def detectCPUs():
      """Detects the number of CPUs on a system.
  
      Cribbed from pp.
  
      """
      # Linux, Unix and MacOS:
      if hasattr(os, 'sysconf'):
          if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
              # Linux & Unix:
              ncpus = os.sysconf('SC_NPROCESSORS_ONLN')
              if isinstance(ncpus, int) and ncpus > 0:
                  return ncpus
          else:  # OSX:
              return int(subprocess.check_output(['sysctl', '-n', 'hw.ncpu'],
                                                 stderr=subprocess.STDOUT))
      # Windows:
      if 'NUMBER_OF_PROCESSORS' in os.environ:
          ncpus = int(os.environ['NUMBER_OF_PROCESSORS'])
          if ncpus > 0:
              # With more than 32 processes, process creation often fails with
              # "Too many open files".  FIXME: Check if there's a better fix.
              return min(ncpus, 32)
      return 1
function_tokens: def detectCPUs ( ) : # Linux, Unix and MacOS: if hasattr ( os , 'sysconf' ) : if 'SC_NPROCESSORS_ONLN' in os . sysconf_names : # Linux & Unix: ncpus = os . sysconf ( 'SC_NPROCESSORS_ONLN' ) if isinstance ( ncpus , int ) and ncpus > 0 : return ncpus else : # OSX: return int ( subprocess . check_output ( [ 'sysctl' , '-n' , 'hw.ncpu' ] , stderr = subprocess . STDOUT ) ) # Windows: if 'NUMBER_OF_PROCESSORS' in os . environ : ncpus = int ( os . environ [ 'NUMBER_OF_PROCESSORS' ] ) if ncpus > 0 : # With more than 32 processes, process creation often fails with # "Too many open files".  FIXME: Check if there's a better fix. return min ( ncpus , 32 ) return 1