question 388 Async Python · medium
A fixed pool of async workers
A thumbnail service processes uploads with a fixed number of async workers fed from an asyncio.Queue, so at most workers jobs run at once. Write process_all(jobs, handle, workers): put every job on a queue, start workers worker tasks that each take jobs and await handle(job) until the queue is empty, and return the results sorted.
Coroutine
async def process_all(jobs, handle, workers)Ruleexactly
workers worker tasks; at most that many handle calls at once; every job handled onceReturnsa sorted list of the results