question 377 Threading & Multiprocessing · medium
Worker threads fed by a queue
A thumbnail service runs a fixed number of worker threads that take jobs from a queue.Queue. Write run_workers(jobs, handle, workers, make_thread=threading.Thread): put every job on the queue, followed by one None per worker as a *stop* signal; each worker loops taking jobs and handling them until it takes a None. Return the results sorted.
Read and diagnose: this can't run in the browser, so you'll read real code and output and answer questions about it.
Function
run_workers(jobs, handle, workers, make_thread=threading.Thread)Workersexactly
workers threads, all started before any is joinedReturnsa sorted list of
handle(job) for every job