[issue21423] concurrent.futures.ThreadPoolExecutor should accept an initializer argument

Dan O'Reilly report at bugs.python.org
Wed Jul 23 17:35:01 CEST 2014


Dan O'Reilly added the comment:

It seems like everyone agrees that this functionality is useful, so I'm reviving this in hopes of getting a patch pushed through. I've updated Andreas' patch so that it applies cleanly against the latest tree, and tweaked the handling of exceptions in initializer. Now, ProcessPoolExecutor will raise a BrokenPoolException should an initializer method fail, and ThreadPoolExecutor will raise a RunTimeError stating that the pool can't be used because an initializer failed.

I was hoping to use multiprocessing.Pool's handling of initializer exceptions as a guide for the right behavior here, but it actually does terrible job: an exception raised in the initializer is completely unhandled, and results in an endless loop of new processes being started up and immediately failing. But that's a separate bug report. :)

For now there are still unit tests for testing exceptions being raised in the initializer, but they're noisy; the traceback for each initializer exception gets printed to stdout. I'm not sure if that's undesirable behavior or not.

If the new behavior looks ok, the docs will need an update to.

----------
nosy: +dan.oreilly
Added file: http://bugs.python.org/file36047/pool_init.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21423>
_______________________________________


More information about the Python-bugs-list mailing list