diff --git a/tests/test_base.py b/tests/test_base.py index 89a82fe4..69a70677 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -799,6 +799,26 @@ async def main(): elif result.returncode != 0: self.fail(result.stdout.strip()) + def test_thread_name_prefix_in_default_executor(self): + if self.implementation == "asyncio" and sys.version_info < (3, 9): + raise unittest.SkipTest( + "thread_name_prefix was added in CPython 3.9" + ) + + called = [] + + def cb(): + called.append(threading.current_thread().name) + + async def runner(): + await self.loop.run_in_executor(None, cb) + + self.loop.run_until_complete(runner()) + + self.assertEqual(len(called), 1) + self.assertTrue(called[0] is not None) + self.assertTrue(called[0].startswith(self.implementation)) + class TestBaseUV(_TestBase, UVTestCase): diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx index b316bd7f..048ddeac 100644 --- a/uvloop/loop.pyx +++ b/uvloop/loop.pyx @@ -2747,7 +2747,7 @@ cdef class Loop: # Only check when the default executor is being used self._check_default_executor() if executor is None: - executor = cc_ThreadPoolExecutor() + executor = cc_ThreadPoolExecutor(thread_name_prefix='uvloop') self._default_executor = executor return aio_wrap_future(executor.submit(func, *args), loop=self)