0

I'm looking to launch several tests in parallel using multiprocessing:

 testlist=[test1, test2, test3]
 pool = ThreadPool(len(testlist))
 try:
      pool.map(run_test, testlist)
      print('Success')
      sys.exit(0)
 except Exception:
      print('FAILURE!')
      sys.exit(1)

Is there a way to get all the threads to terminate if one of them throws an exception? It makes no sense to run all the tests if one fails early.

Ray Salemi
  • 5,247
  • 4
  • 30
  • 63

1 Answers1

0

You can't kill thread. Calling pool.terminate() will only prevent the creating of new thread.
The test already running will not be stopped.
See: https://stackoverflow.com/a/325528/7529716

Yassine Faris
  • 951
  • 6
  • 26