Skip to content

Set the thread_name_prefix for asyncio's default executor ThreadPoolExecutor #83790

Closed

Description

@mmohrhard
mannequin
BPO 39609
Nosy @asvetlov, @cjrh, @1st1, @miss-islington, @mmohrhard
PRs
  • bpo-39609: set the thread_name_prefix for the default asyncio executor #18458
  • 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:

    assignee = None
    closed_at = <Date 2020-02-27.20:02:17.477>
    created_at = <Date 2020-02-11.11:35:18.867>
    labels = ['type-feature', '3.9', 'expert-asyncio']
    title = "Set the thread_name_prefix for asyncio's default executor ThreadPoolExecutor"
    updated_at = <Date 2020-02-27.20:02:17.477>
    user = 'https://github.com/mmohrhard'

    bugs.python.org fields:

    activity = <Date 2020-02-27.20:02:17.477>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-02-27.20:02:17.477>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2020-02-11.11:35:18.867>
    creator = 'Markus Mohrhard'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39609
    keywords = ['patch']
    message_count = 4.0
    messages = ['361799', '362162', '362177', '362832']
    nosy_count = 5.0
    nosy_names = ['asvetlov', 'cjrh', 'yselivanov', 'miss-islington', 'Markus Mohrhard']
    pr_nums = ['18458']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue39609'
    versions = ['Python 3.9']

    Activity

    1. mmohrhard commented on Feb 11, 2020

      mmohrhardmannequin
      MannequinAuthor

      The ThreadPoolExecutor in BaseEventLoop.run_in_executor should set a thread_name_prefix to simplify debugging.

      Might also be worth to limit the number of max threads. On our 256 core machines we sometimes get 1000+ threads due to the cpu_count() * 5 default limit.

    2. cjrh commented on Feb 17, 2020

      cjrhmannequin
      Mannequin

      This change seems fine.

      Markus,

      I'm curious if there is a specific reason you prefer to use the default executor rather than replacing it with your own? Is it just convenience or are there other reasons?

    3. mmohrhard commented on Feb 18, 2020

      mmohrhardmannequin
      MannequinAuthor

      We have by now changed to a custom executor. Asyncio is used in some of our dependencies and therefore it took some work to figure out what is creating the thousands of threads that we were seeing.

      This patch was part of the debuggin and we thought it would be useful for anyone else to immediately see what is creating the threads.

    4. miss-islington commented on Feb 27, 2020

      @miss-islington
      Contributor

      New changeset 374d998 by Markus Mohrhard in branch 'master':
      bpo-39609: set the thread_name_prefix for the default asyncio executor (GH-18458)
      374d998

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions