title: Understanding process pool : how does a process pool use wait() to reap child process?
body: <p>if a process pool is created and there are 10 processes
  but my program only use 4 processes
  it means there are 6 idle processes</p>
  
  <p>to use a process pool,
  generally the pseudo code is like:</p>
  
  <pre><code>pool=create_process_pool(M)
  for i in 1:N:
      pool.run(task i)
  pool.wait()
  pool.close()
  </code></pre>
  
  <p>how does the pool decide when to call pool.wait()?
  there are some cases:</p>
  
  <p>1 if M>N, for example M=10, N=6, then there are 4 idle processes. For the 6 used processes, when they finished running and exit, they can inform the pool.wait(), but for the 4 idle processes, since they didn't run, how can they inform the pool.wait() that they finishes?</p>
  
  <p>2 if M &lt; N, is a process finishes a task and exit, it may be used for another task. So how can this process know that it will have no tasks any more and so inform pool.wait()</p>
  
  <p>can anyone explain a bit how process pool works in this regard?
  thanks!</p>