Practice ยท 1 of 1
Bounded async pipeline
Implement async def pipeline(items, transform, workers=2, maxsize=3):
- put all items through an asyncio.Queue(maxsize=maxsize)
- workers async tasks consume and append await transform(item) results
- the producer must NOT dump everything into the queue at once โ with maxsize honored, queue backpressure applies (await q.put suspends when full)
- return sorted(results) after await q.join(); cancel the workers afterwards
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Bounded Queue Practice