title: Portable way of detecting number of *usable* CPUs in Python
body: <p>Per this question and answer -- <a href="https://stackoverflow.com/q/31344582/1337498">Python multiprocessing.cpu_count() returns &#39;1&#39; on 4-core Nvidia Jetson TK1</a> --  the output of Python's <code>multiprocessing.cpu_count()</code> function on certain systems reflects the number of CPUs actively <em>in use</em>, as opposed to the number of CPUs actually <em>usable</em> by the calling Python program.</p>
  
  <p>A common Python idiom is to use the return-value of <code>cpu_count()</code> to initialize the number of processes in a <code>Pool</code>. However, on systems that use such a "dynamic CPU activation" strategy, that idiom breaks rather badly (at least on a relatively quiescent system). </p>
  
  <p>Is there some straightforward (and portable) way to get at the number of <strong>usable</strong> processors (as opposed the number <em>currently in use</em>) from Python?</p>
  
  <p><strong>Notes:</strong></p>
  
  <ol>
  <li><p>This question is not answered by the accepted answer to <a href="https://stackoverflow.com/questions/1006289/how-to-find-out-the-number-of-cpus-using-python">How to find out the number of CPUs using python</a>, since as noted in the question linked at the top of <em>this</em> question, printing the contents of <code>/proc/self/status</code> shows all 4 cores as being available to the program.</p></li>
  <li><p>To my mind, "portable" excludes any approach that involves parsing the contents of <code>/proc/self/status</code>, whose format may vary from release to release of Linux, and which doesn`t even exist on OS X. (The same goes for any other pseudo-file, as well.)</p></li>
  </ol>