title: Check if a process in multiprocessing.Pool has crashed
body: <p>I'm running some code using an external C library that very rarely crashes. I've wrapped this code using a <code>multiprocessing.Pool</code> to run it in parallel. I'd like to be able to detect if one of the processes in the pool has segfaulted. From <a href="https://stackoverflow.com/questions/7327211/python-multiprocessing-pool-with-processes-that-crash">this question,</a> it sounds like I need to reimplement the pool using <code>multiprocessing.Process</code> in such a way that I can check the <code>is_alive()</code> but I'm not sure how to do that.</p>
  
  <p>For example:</p>
  
  <pre><code>import multiprocessing
  import time
  
  def fn(arg):
      if arg == 4:
          # this should segfault
          # http://codegolf.stackexchange.com/questions/4399/shortest-code-that-return-sigsegv
          import ctypes;ctypes.string_at(0)
  
      time.sleep(2)    
      return arg**2
  
  def main():
      pool = multiprocessing.Pool()
  
      inputs = range(10)
      results = pool.map_async(fn, inputs)
  
      while True:
          if results.ready():
              break
  
          time.sleep(0.5)
          print "status: still running..."
  
          # ... some async code ...
          # detect failed process here?
  
      outputs = results.get()
  
      print outputs
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>How could I re-write this to detect the segfault? (Also, I tried running it with python 3.5.0 and it didn't seem to raise an exception as suggested in that other question.)</p>