diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py index 03d276b63f..0d07b4a429 100644 --- a/Lib/concurrent/futures/thread.py +++ b/Lib/concurrent/futures/thread.py @@ -125,8 +125,11 @@ class ThreadPoolExecutor(_base.Executor): # idle threads than items in the work queue. num_threads = len(self._threads) if num_threads < self._max_workers: - thread_name = '%s_%d' % (self._thread_name_prefix or self, - num_threads) + if self._thread_name_prefix: + thread_name = '%s_%d' % (self._thread_name_prefix, + num_threads) + else: + thread_name = None t = threading.Thread(name=thread_name, target=_worker, args=(weakref.ref(self, weakref_cb), self._work_queue)) diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index 23e95b2124..5cd985363e 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -172,10 +172,7 @@ class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, unittest.Tes del executor for t in threads: - # We don't particularly care what the default name is, just that - # it has a default name implying that it is a ThreadPoolExecutor - # followed by what looks like a thread number. - self.assertRegex(t.name, r'^.*ThreadPoolExecutor.*_[0-4]$') + self.assertRegex(t.name, r'^Thread-[0-9]+$') t.join()