fix: set task name earlier for logging (#8333)

This commit is contained in:
cthomas
2026-01-06 11:00:20 -08:00
committed by Caren Thomas
parent 02700cdae2
commit 485fe9d1b2

View File

@@ -1445,11 +1445,12 @@ async def bounded_gather(coros: list[Coroutine], max_concurrency: int = 10) -> l
semaphore = asyncio.Semaphore(max_concurrency)
async def bounded_coro(index: int, coro: Coroutine, coro_name: str):
# Set task name for diagnostics before acquiring semaphore
task = asyncio.current_task()
if task:
task.set_name(f"bounded[{coro_name}]")
async with semaphore:
# Set task name for diagnostics
task = asyncio.current_task()
if task:
task.set_name(f"bounded[{coro_name}]")
result = await coro
return (index, result)