python / cpython

The Python programming language
https://www.python.org
Other
62.38k stars 29.96k forks source link

Interpreter exit blocks waiting for ThreadPoolExecutor.map #86575

Open e183a343-e457-4baf-97bd-5e6a2e096b0d opened 3 years ago

e183a343-e457-4baf-97bd-5e6a2e096b0d commented 3 years ago
BPO 42409
Files
  • threadpool_map.py
  • 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'] ```

    e183a343-e457-4baf-97bd-5e6a2e096b0d commented 3 years ago

    ThreadPoolExecutor.map() prevents interpreter exit if there is a reference to the generator it returns. In the attached script:

    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).