Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
2 changes: 1 addition & 1 deletion uvloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading