This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Hooking Thread/Process instantiation in concurrent.futures.
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument
View: 21423
Assigned To: Nosy List: Antony.Lee, pitrou, yselivanov
Priority: normal Keywords:

Created on 2015-10-01 22:09 by Antony.Lee, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg252067 - (view) Author: Antony Lee (Antony.Lee) * Date: 2015-10-01 22:09
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?
msg305455 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-11-02 22:55
I'd rather close this in favour of issue21423.
msg305457 - (view) Author: Antony Lee (Antony.Lee) * Date: 2017-11-02 23:01
I can't say I *really* need this anymore, but note that https://bugs.python.org/issue21423 is less general as it does not handle the case of a finalizer as proposed here.
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69480
2017-11-02 23:01:21Antony.Leesetmessages: + msg305457
2017-11-02 22:55:23pitrousetstatus: open -> closed

superseder: concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument

nosy: + pitrou
messages: + msg305455
resolution: duplicate
stage: resolved
2015-10-02 17:04:42yselivanovsetnosy: + yselivanov
2015-10-01 22:09:12Antony.Leecreate