title: Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?
body: <pre><code>mp.set_start_method('spawn')
  total_count = Counter(0)
  pool = mp.Pool(initializer=init, initargs=(total_count,), processes=num_proc)    
  
  pool.map(part_crack_helper, product(seed_str, repeat=4))
  pool.close()
  pool.join()
  </code></pre>
  
  <p>So I have a pool of worker process that does some work. It just needs to find one solution. Therefore, when one of the worker processes finds the solution, I want to stop everything. </p>
  
  <p>One way I thought of was just calling sys.exit(). However, that doesn't seem like it's working properly since other processes are running.</p>
  
  <p>One other way was to check for the return value of each process calls (the return value of part_crack_helper function) and call terminate on that process. However, I don't know how to do that when using that map function.</p>
  
  <p>How should I achieve this?</p>