Wrap the worker coroutine in async with sem: where sem = asyncio.Semaphore(10), and run tasks with asyncio.TaskGroup (Python 3.11+) for fail-fast cancellation or asyncio.gather(..., return_exceptions=True) when partial successes should be recorded.
Follow-up Interview Question · How does asyncio.TaskGroup improve error handling over bare asyncio.gather?