Issue 25293: Hooking Thread/Process instantiation in concurrent.futures. (original) (raw)
http://bugs.python.org/issue21423 and http://bugs.python.org/issue24980 suggest adding an initializer/on_new_thread argument to {Thread,Process}PoolExecutor. I would like to suggest a more unified API, that would allow not only handling initialization, but also finalization, by adding a {thread,process}_class attribute / constructor argument to {Thread,Process}PoolExecutor, so that one could do:
class MyThread(Thread): def run(self): initialize() try: super().run() finally: finalize()
with ThreadPoolExecutor(thread_class=MyThread): ...
Thoughts?