title: Multiprocessing, what does pool.ready do?
body: <p>Suppose I have a pool with a few processes inside of a class that I use to do some processing, like this:</p>
  
  <pre><code>class MyClass:
  
      def __init_(self):
          self.pool = Pool(processes = NUM_PROCESSES)
          self.pop = []
          self.finished = []
  
      def gen_pop(self):
          self.pop = [ self.pool.apply_async(Item.test, (Item(),)) for _ in range(NUM_PROCESSES) ]
          while (not self.check()):
              continue
          # Do some other stuff
  
      def check(self):
          self.finished = filter(lambda t: self.pop[t].ready(), range(NUM_PROCESSES))
          new_pop = []
          for f in self.finished:
              new_pop.append(self.pop[f].get(timeout = 1))
              self.pop[f] = None
              # Do some other stuff
  </code></pre>
  
  <p>When I run this code I get a <code>cPickle.PicklingError</code> which states that a <code>&lt;type 'function'&gt;</code> can't be pickled.  What this tells me is that one of the <code>apply_async</code> functions has not returned yet so I am attempting to append a running function to another list. But this shouldn't be happening because all running calls should have been filtered out using the <code>ready()</code> function.</p>
  
  <p>On a related note, the actual nature of the <code>Item</code> class is unimportant but what is important is that at the top of my <code>Item.test</code> function I have a print statement which is supposed to fire for debugging purposes. However, that does not occur. This tells me that that the function has been initiated but has not actually started execution.</p>
  
  <p>So then, it appears that <code>ready()</code> does not actually tell me whether or not a call has finished execution or not. What exactly does <code>ready()</code> do and how should I edit my code so that I can filter out the processes that are still running?</p>