Python: Can you set cpu counts with multiprocessing Process
<p>With <code>multiprocessing.Pool</code>, there are code samples in the tutorials  where you can set number of processes with cpu counts. Can you set the number of cpu's with the <code>multiprocessing.Process</code> method. </p>

<pre><code>from multiprocessing import Process, Value, Array

def f(n, a):
    n.value = 3.1415927
    for i in range(len(a)):
        a[i] = -a[i]

if __name__ == '__main__':
    num = Value('d', 0.0)
    arr = Array('i', range(10))

    p = Process(target=f, args=(num, arr))
    p.start()
    p.join()

    print(num.value)
    print(arr[:])
</code></pre>

<p>Actually <code>Process</code> represents only one process which uses only one CPU (if you dont use threads) - it is up to you to create as many <code>Process</code>es as you need. </p>

<p>This means that you have to create as many <code>Process</code>es as you have CPUs to use all of them (possibly -1 if you are doing things in the main process)</p>

<p>You can read the number of CPUs with <a href="https://docs.python.org/3/library/multiprocessing.html#multiprocessing.cpu_count" rel="nofollow">multiprocessing.cpu_count</a></p>

python multiprocessing cpu