title: Terminate a Python multiprocessing program once a one of its workers meets a certain condition
body: <p>I am writing a Python program using its multiprocessing module. The program calls a number of worker functions, each yielding a random number. <strong>I need to terminate the program once one of the workers has produced a number larger than 0.7</strong>. </p>
  
  <p>Below is my program where the "<em>how to do this</em>" part is not yet filled out. Any idea? Thanks.</p>
  
  <pre><code>import time
  import numpy as np
  import multiprocessing as mp
  import time
  import sys
  
  def f(i):
      np.random.seed(int(time.time()+i))
  
      time.sleep(3)
      res=np.random.rand()
      print "From i = ",i, "       res = ",res
      if res&gt;0.7:
          print "find it"
          # terminate  ???? Question: How to do this???
  
  
  if __name__=='__main__':
      num_workers=mp.cpu_count()
      pool=mp.Pool(num_workers)
      for i in range(num_workers):
          p=mp.Process(target=f,args=(i,))
          p.start()
  </code></pre>