Gets the setting value as an integer relative to the number of CPU.
        See :func:`ycsettings.settings.parse_n_jobs` for parsing rules.

        :rtype: int
199015
def getnjobs(self, key, **kwargs):
        

        return self.get(key, cast_func=parse_n_jobs, **kwargs)
126430
def set(self, num):
        
        self._value = str(int(num))
        self._variable.set(self._value)
336566
def get_cpu_usage(self, cpu_id=0):
        

        cpu_usage = yield from self._hypervisor.send('vm cpu_usage "{name}" {cpu_id}'.format(name=self._name, cpu_id=cpu_id))
        return int(cpu_usage[0])
678164
def num_unused_cpus(thresh=10):
    
    import psutil
    cpu_usage = psutil.cpu_percent(percpu=True)
    return sum([p < thresh for p in cpu_usage])
649530
def set_runtime_value_int(self, resourceid: int, intvalue: int):
        """"""
        payload = """
            <setResourceValue1 xmlns=\"utcs\"
            xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">
            <value i:type=\"a:WSIntegerValue\" xmlns:a=\"utcs.values\">
            <a:integer>{value}</a:integer></value>
            <typeString/>
            <resourceID>{id}</resourceID>
            <isValueRuntime>true</isValueRuntime>
            </setResourceValue1>
            """.format(id=resourceid, value=intvalue)
        xdoc = self.connection.soap_action('/ws/ResourceInteractionService',
                                           'setResourceValue', payload)
        if xdoc:
            result = xdoc.find('./SOAP-ENV:Body/ns1:setResourceValue2',
                               IHCSoapClient.ihcns).text
            return result == "true"
        return False
340938
def _get_cores_and_type(numcores, paralleltype, scheduler):
    
    if scheduler is not None:
        paralleltype = "ipython"
    if paralleltype is None:
        paralleltype = "local"
    if not numcores or int(numcores) < 1:
        numcores = 1
    return paralleltype, int(numcores)
76097
@CommandArgument
  public void setcpus(int numberOfCpus) {
    if (worker == null) {
      System.err.println("Worker not running.");
      return;
    }
    int availableCpus = Runtime.getRuntime().availableProcessors();
    if (numberOfCpus <= 0 || numberOfCpus > availableCpus) {
      numberOfCpus = availableCpus;
    }
    System.out.printf("Setting number of CPUs to %d\n", numberOfCpus);
    worker.setMaxWorkers(numberOfCpus);
  }
51063
def int(name, default=None, allow_none=False, fallback=None):
    
    value = read(name, default, allow_none, fallback=fallback)
    if isinstance(value, builtins.str):
        value = value.strip()

    if value is None and allow_none:
        return None
    else:
        return builtins.int(value)
924563
public int getThreadNumber() {
        if (cli.hasOption(THREAD_NUMBER)) {
            return Integer.valueOf(cli.getOptionValue(THREAD_NUMBER));
        }

        return DEFAULT_THREAD_NUMBER;
    }
916805
def next_int(self, n=None):
        
        if n is None:
            return javabridge.call(self.jobject, "nextInt", "()I")
        else:
            return javabridge.call(self.jobject, "nextInt", "(I)I", n)
67797
def calculate_usage(self, cpu, total, busy):
        
        diff_total = total - self.prev_total[cpu]
        diff_busy = busy - self.prev_busy[cpu]

        self.prev_total[cpu] = total
        self.prev_busy[cpu] = busy

        if diff_total == 0:
            return 0
        else:
            return int(diff_busy / diff_total * 100)
1121179
def get_int(value, default, test_fn=None):
    
    try:
        converted = int(value)
    except ValueError:
        return default

    test_fn = test_fn if test_fn else lambda x: True
    return converted if test_fn(converted) else default
437571
public static int getNumCores() {
        class CpuFilter implements FileFilter {
            @Override
            public boolean accept(File pathname) {
                return Pattern.matches("cpu[0-9]", pathname.getName());
            }
        }

        if (sCoreNum == 0) {
            try {
                // Get directory containing CPU info
                File dir = new File("/sys/devices/system/cpu/");
                // Filter to only list the devices we care about
                File[] files = dir.listFiles(new CpuFilter());
                // Return the number of cores (virtual CPU devices)
                sCoreNum = files.length;
            } catch (Exception e) {
                Log.e(TAG, "getNumCores exception", e);
                sCoreNum = 1;
            }
        }
        return sCoreNum;
    }
185185
def _obtain_queue(num_jobs):
    
    if _should_use_multiprocessing(num_jobs):
        return ReprQueue(multiprocessing.Manager().Queue())

    return ReprQueue(Queue())
796151
def _get_cpu_count(self):
        """"""
        try:
            from multiprocessing import cpu_count

            return cpu_count()
        except Exception as e:
            Config.main_logger.error("_get_cpu_count failed for %s" % e)
437074
def _windows_cpudata():
    '''
    
    '''
    # Provides:
    #   num_cpus
    #   cpu_model
    grains = {}
    if 'NUMBER_OF_PROCESSORS' in os.environ:
        # Cast to int so that the logic isn't broken when used as a
        # conditional in templating. Also follows _linux_cpudata()
        try:
            grains['num_cpus'] = int(os.environ['NUMBER_OF_PROCESSORS'])
        except ValueError:
            grains['num_cpus'] = 1
    grains['cpu_model'] = salt.utils.win_reg.read_value(
        hive="HKEY_LOCAL_MACHINE",
        key="HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
        vname="ProcessorNameString").get('vdata')
    return grains
634609
def __get_cpu(self):
        """"""
        # Never update more than 1 time per cached_time
        if self.timer_cpu.finished():
            self.cpu_percent = psutil.cpu_percent(interval=0.0)
            # Reset timer for cache
            self.timer_cpu = Timer(self.cached_time)
        return self.cpu_percent