title: Stop multiples threads if error ocurred and keep running the main thread ? Python
body: <p>Is there a way to stop all threads in the list if an error occurs in any of them without stopping the main thread ?</p>
  
  <pre><code>from threading import Thread
  
  def build_packages(pkg_id):
      try:
          # do something
      except Exception:
          # stop all threads except main thread
  
  threads = []
  
  for pkg_id in pkgs:
      t = Thread(target=build_packages, args=[pkg_id])
  
      threads.append(t)
      t.setDaemon(True)
      t.start()
  
  for t in threads:
      t.join()
  </code></pre>