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.

Title: Set the thread_name_prefix for asyncio's default executor ThreadPoolExecutor
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Markus Mohrhard, asvetlov, cjrh, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2020-02-11 11:35 by Markus Mohrhard, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18458 open Markus Mohrhard, 2020-02-11 11:39
Messages (4)
msg361799 - (view) Author: Markus Mohrhard (Markus Mohrhard) * Date: 2020-02-11 11:35
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.
msg362162 - (view) Author: Caleb Hattingh (cjrh) * Date: 2020-02-17 23:14
This change seems fine.


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?
msg362177 - (view) Author: Markus Mohrhard (Markus Mohrhard) * Date: 2020-02-18 07:57
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.
msg362832 - (view) Author: miss-islington (miss-islington) Date: 2020-02-27 20:01
New changeset 374d998b507d34a6c0a3816a163926a8ba0c483f by Markus Mohrhard in branch 'master':
bpo-39609: set the thread_name_prefix for the default asyncio executor (GH-18458)
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83790
2020-02-27 20:02:17asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-02-27 20:01:59miss-islingtonsetnosy: + miss-islington
messages: + msg362832
2020-02-18 07:57:01Markus Mohrhardsetmessages: + msg362177
2020-02-17 23:14:15cjrhsetnosy: + cjrh
messages: + msg362162
2020-02-11 11:39:10Markus Mohrhardsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17832
2020-02-11 11:35:18Markus Mohrhardcreate