Message326231
I think it raises BrokenThreadPool . A sample program that I tried as below raising an exception in the initializer. Maybe I am wrong here. Can you please attach a script that triggers BrokenProcessPool?
# bpo34786.py
import concurrent.futures
import time
def bar(i):
raise Exception(i) # Raise exception from the initializer
def foo(i):
time.sleep(i)
return "1"
with concurrent.futures.ThreadPoolExecutor(max_workers=5,
initializer=bar, initargs=(1,)) as executor:
future_to_url = {executor.submit(foo, i, 60): i for i in range(10)}
for future in concurrent.futures.as_completed(future_to_url):
try:
data = future.result()
except Exception as exc:
print('generated an exception: %s' % (exc))
else:
print('%d bytes' % (len(data)))
# Run the program
./python.exe ../backups/bpo34786.py
Exception in initializer:
Traceback (most recent call last):
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/concurrent/futures/thread.py", line 69, in _worker
initializer(*initargs)
File "../backups/bpo34786.py", line 5, in bar
raise Exception(i)
Exception: 1
Exception in initializer:
Traceback (most recent call last):
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/concurrent/futures/thread.py", line 69, in _worker
initializer(*initargs)
File "../backups/bpo34786.py", line 5, in bar
raise Exception(i)
Exception: 1
Traceback (most recent call last):
File "../backups/bpo34786.py", line 13, in <module>
future_to_url = {executor.submit(foo, i, 60): i for i in range(10)}
File "../backups/bpo34786.py", line 13, in <dictcomp>
future_to_url = {executor.submit(foo, i, 60): i for i in range(10)}
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/concurrent/futures/thread.py", line 148, in submit
raise BrokenThreadPool(self._broken)
concurrent.futures.thread.BrokenThreadPool: A thread initializer failed, the thread pool is not usable anymore
Thanks |
|
Date |
User |
Action |
Args |
2018-09-24 12:51:52 | xtreak | set | recipients:
+ xtreak, docs@python, kahara |
2018-09-24 12:51:52 | xtreak | set | messageid: <1537793512.12.0.956365154283.issue34786@psf.upfronthosting.co.za> |
2018-09-24 12:51:52 | xtreak | link | issue34786 messages |
2018-09-24 12:51:52 | xtreak | create | |
|