Joni Kähärä <joni.kah...@async.fi> added the comment: Perhaps I wasn't clear that this considered ProcessPoolExecutor documentation, not ThreadPoolExecutor. Taking the example from documentation and adding an initializer like this:
import concurrent.futures import math PRIMES = [ 112272535095293, 112582705942171, 112272535095293, 115280095190773, 115797848077099, 1099726899285419] def is_prime(n): if n % 2 == 0: return False sqrt_n = int(math.floor(math.sqrt(n))) for i in range(3, sqrt_n + 1, 2): if n % i == 0: return False return True def init(): raise Exception() def main(): with concurrent.futures.ProcessPoolExecutor(initializer=init) as executor: for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)): print('%d is prime: %s' % (number, prime)) if __name__ == '__main__': main() ...yields the following: Exception in initializer: Traceback (most recent call last): File "/Users/developer/cpython/Lib/concurrent/futures/process.py", line 219, in _process_worker initializer(*initargs) File "/tmp/bpo34786.py", line 25, in init raise Exception() Exception Exception in initializer: Traceback (most recent call last): File "/Users/developer/cpython/Lib/concurrent/futures/process.py", line 219, in _process_worker initializer(*initargs) File "/tmp/bpo34786.py", line 25, in init raise Exception() Exception Exception in initializer: Traceback (most recent call last): File "/Users/developer/cpython/Lib/concurrent/futures/process.py", line 219, in _process_worker initializer(*initargs) File "/tmp/bpo34786.py", line 25, in init raise Exception() Exception Exception in initializer: Traceback (most recent call last): File "/Users/developer/cpython/Lib/concurrent/futures/process.py", line 219, in _process_worker initializer(*initargs) File "/tmp/bpo34786.py", line 25, in init raise Exception() Exception Traceback (most recent call last): File "/tmp/bpo34786.py", line 33, in <module> main() File "/tmp/bpo34786.py", line 29, in main for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)): File "/Users/developer/cpython/Lib/concurrent/futures/process.py", line 476, in _chain_from_iterable_of_lists for element in iterable: File "/Users/developer/cpython/Lib/concurrent/futures/_base.py", line 594, in result_iterator yield fs.pop().result() File "/Users/developer/cpython/Lib/concurrent/futures/_base.py", line 436, in result return self.__get_result() File "/Users/developer/cpython/Lib/concurrent/futures/_base.py", line 388, in __get_result raise self._exception concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34786> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com