title: multiprocessing.Pool spawning new childern after terminate() on Linux/Python2.7?
body: <p>I have an executable file which I need to run very often, with different parameters. For this I wrote a small Python (2.7) wrapper, using the multiprocessing module, following the pattern given <a href="https://stackoverflow.com/a/2561809/152439.">here</a>.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>try:
       logging.info("starting pool runs")
       pool.map(run_nlin, params)
       pool.close()
   except KeyboardInterrupt:
       logging.info("^C pressed")
       pool.terminate()
   except Exception, e:
       logging.info("exception caught: ", e)
       pool.terminate()
   finally:
       time.sleep(5)
       pool.join()
       logging.info("done")
  </code></pre>
  
  <p>My worker function is here:</p>
  
  <pre><code>class KeyboardInterruptError(Exception): pass
  
  def run_nlin((path_config, path_log, path_nlin, update_method)):
      try:
          with open(path_log, "w") as log_:
              cmdline = [path_nlin, path_config]
              if update_method:
                  cmdline += [update_method, ]
              sp.call(cmdline, stdout=log_, stderr=log_)
      except KeyboardInterrupt:
          time.sleep(5)
          raise KeyboardInterruptError()
      except:
          raise
  </code></pre>
  
  <p><code>path_config</code> is the path to a configuration file for the binary program; in there is e.g. the date to run the program for.</p>
  
  <p>When I start the wrapper, everything looks fine. However, when I press <code>^C</code>, the wrapper script seems to launch an additional <code>numproc</code> processes from the pool before terminating. As an example, when I start the script for days 1-10, I can see in the <code>ps aux</code> output that two instances of the binary program are running (usually for days 1 and 3). Now, when I press <code>^C</code>, the wrapper script exits, the binary programs for days 1 and 3 are gone, but there are new binary programs running for days 5 and 7.</p>
  
  <p>So to me it seems as if the <code>Pool</code> launches another <code>numproc</code> processes before finally dying.</p>
  
  <p>Any ideas what's happening here, and what I can do about it?</p>