Open e183a343-e457-4baf-97bd-5e6a2e096b0d opened 3 years ago
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).
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at = None created_at =
labels = ['3.7', '3.8', 'type-bug', 'library']
title = 'Interpreter exit blocks waiting for ThreadPoolExecutor.map'
updated_at =
user = 'https://bugs.python.org/gsakkis'
```
bugs.python.org fields:
```python
activity =
actor = 'stefosgiwrgos'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation =
creator = 'gsakkis'
dependencies = []
files = ['49608']
hgrepos = []
issue_num = 42409
keywords = []
message_count = 1.0
messages = ['381433']
nosy_count = 2.0
nosy_names = ['gsakkis', 'stefosgiwrgos']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue42409'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']
```