3 Feb 2020 3 Feb '20
Hmm, it should be possible. Do you specifically mean cancelling the pending futures once a single one of the submitted functions raises an exception, or cancelling the pending futures when the Executor itself raises an exception (I.E. BrokenProcessPool)? I would assume the prior, since that seems more useful to me.
I was referring to any exception within the context manager of the executor, not the futures or just the executor's exceptions, something such as the following:
with ThreadPoolExecutor(cancel_on_error=True) as executor: # Code here raise Exception
Then if Executor.__exit__ detects an exception it would call shutdown with cancel_futures set to True.