New submission from George Sakkis <george.sak...@gmail.com>:
ThreadPoolExecutor.map() prevents interpreter exit if there is a reference to the generator it returns. In the attached script: - `python threadpool_map.py run1` exits as soon as the exception is raised on the main thread. This is the desired behavior in our case. - `python threadpool_map.py run2` keeps running until the thread worker processes all queued work items. The only difference from `run1` is that the result of `ThreadPoolExecutor.map()` is assigned to a variable. - `python threadpool_map.py run3` has a `finally` block that shuts down the executor without waiting. Still the worker thread keeps running even after the shutdown. Initially it seemed like https://bugs.python.org/issue36780 but there is no change in the behavior after commenting out the `atexit.register(_python_exit)` call (for the `run2` case at least). ---------- components: Library (Lib) files: threadpool_map.py messages: 381433 nosy: gsakkis priority: normal severity: normal status: open title: Interpreter exit blocks waiting for ThreadPoolExecutor.map type: behavior versions: Python 3.6, Python 3.7, Python 3.8 Added file: https://bugs.python.org/file49608/threadpool_map.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42409> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com