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)
+import _thread
import asyncio
import contextlib
import io
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):