PythiloLesson 6 of 12 · progress kept in this browser

Bound task creation as well as active calls

A semaphore limits active work, but creating one task per input can still exhaust memory before any result finishes. A fixed set of workers with a shared iterator bounds both task count and active calls. Preserve input indices so concurrent completion does not reorder the public result.

TaskGroup gives the workers one failure boundary. If one fails, siblings are cancelled and awaited before control leaves the group. This exercise deliberately accepts a finite iterable and an asynchronous operation; unbounded streams need a separate result-consumption and backpressure contract.

import asyncio
async def main():
    queue=asyncio.Queue(maxsize=1)
    await queue.put("one")
    print(queue.full())
    print(await queue.get())
    queue.task_done()
asyncio.run(main())
Your task

Implement async bounded_map(values,call,limit). Create at most limit worker tasks, preserve result order, reject limit<1, and propagate worker failures through TaskGroup.