title: How can you code a nested concurrency in python?
body: <p>My code has the following scheme:</p>
  
  <pre><code>class A():
      def evaluate(self):
          b = B()
          for i in range(30):
              b.run()
  
  class B():
      def run(self):
          pass
  
  if __name__ == '__main__':
      a = A()
      for i in range(10):
          a.evaluate()
  </code></pre>
  
  <p>And I want to have two level of concurrency, the first one is on the <code>evaluate</code> method and the second one is on the <code>run</code> method (nested concurrency). The question is how to introduce this concurrency using the <a href="https://docs.python.org/3.5/library/multiprocessing.html" rel="nofollow noreferrer">Pool class of the multiprocessing</a> module? Should I pass explicitly number of cores?. The solution should not create processes greater than number of  <code>multiprocessing.cpu_count()</code>. </p>
  
  <p>note: assume that number of cores is greater than 10 .</p>
  
  <p><strong>Edit:</strong>
  I have seen a lot of comments that say that python does not have true concurrency due to GIL, this is true for python multi-threading but for multiprocessing this is not quit correct look <a href="https://stackoverflow.com/questions/18114285/what-are-the-differences-between-the-threading-and-multiprocessing-modules">here</a>, also I have timed it also this <a href="https://hackernoon.com/concurrent-programming-in-python-is-not-what-you-think-it-is-b6439c3f3e6a" rel="nofollow noreferrer">article</a> did, and the results show that it can go faster than sequential execution.</p>