parameters: ()
return_statement: return 1
docstring: Detects the number of CPUs on a system.
      This approach is from detectCPUs here: http://www.artima.com/weblogs/viewpost.jsp?thread=230001
docstring_summary: Detects the number of CPUs on a system.
      This approach is from detectCPUs here: http://www.artima.com/weblogs/viewpost.jsp?thread=230001
docstring_tokens: Detects the number of CPUs on a system . This approach is from detectCPUs here : http : // www . artima . com / weblogs / viewpost . jsp?thread = 230001
function: def numCPUs():
      """
      Detects the number of CPUs on a system.
      This approach is from detectCPUs here: http://www.artima.com/weblogs/viewpost.jsp?thread=230001
      """
      # 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:
              p = subprocess.Popen("sysctl -n hw.ncpu", shell=True, stdout=subprocess.PIPE)
              return p.stdout.read()
              
      # Windows:
      if "NUMBER_OF_PROCESSORS" in os.environ:
              ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
              if ncpus > 0:
                  return ncpus
      return 1
function_tokens: def numCPUs ( ) : # 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: p = subprocess . Popen ( "sysctl -n hw.ncpu" , shell = True , stdout = subprocess . PIPE ) return p . stdout . read ( ) # Windows: if "NUMBER_OF_PROCESSORS" in os . environ : ncpus = int ( os . environ [ "NUMBER_OF_PROCESSORS" ] ) if ncpus > 0 : return ncpus return 1