gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run

The OS thread name is now correctly prefixed with `InterpreterPoolExecutor` instead of `ThreadPoolExecutor`.
This commit is contained in:
AN Long 2025-07-21 08:34:32 +09:00 committed by GitHub
parent aec7f5f8b2
commit 246be21de1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View file

@ -118,5 +118,7 @@ class InterpreterPoolExecutor(_thread.ThreadPoolExecutor):
each worker interpreter.
initargs: A tuple of arguments to pass to the initializer.
"""
thread_name_prefix = (thread_name_prefix or
(f"InterpreterPoolExecutor-{self._counter()}"))
super().__init__(max_workers, thread_name_prefix,
initializer, initargs)

View file

@ -1,3 +1,4 @@
import _thread
import asyncio
import contextlib
import io
@ -498,6 +499,20 @@ class InterpreterPoolExecutorTest(
self.assertEqual(p.stdout.decode(), '')
self.assertEqual(p.stderr.decode(), '')
def test_thread_name_prefix(self):
self.assertStartsWith(self.executor._thread_name_prefix,
"InterpreterPoolExecutor-")
@unittest.skipUnless(hasattr(_thread, '_get_name'), "missing _thread._get_name")
def test_thread_name_prefix_with_thread_get_name(self):
def get_thread_name():
import _thread
return _thread._get_name()
# Some platforms (Linux) are using 16 bytes to store the thread name,
# so only compare the first 15 bytes (without the trailing \n).
self.assertStartsWith(self.executor.submit(get_thread_name).result(),
"InterpreterPoolExecutor-"[:15])
class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase):

View file

@ -0,0 +1,2 @@
Correct :class:`concurrent.futures.InterpreterPoolExecutor`'s default thread
name.