runtime
388 / 500
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.

Coroutineasync def process_all(jobs, handle, workers)
Ruleexactly workers worker tasks; at most that many handle calls at once; every job handled once
Returnsa sorted list of the results

Loading your progress…

A fixed pool of async workers — Python practice · Runtime