A pattern for using concurrent.futures.ThreadPoolExecutor()
to execute a series of "worker" functions in parallel, processing a queue of assigned "work".
How it works:
worker_init()
creates:- Queues for "work" and "results".
- A
threading.Event()
to denote "no more work in queue". - A
futures.ThreadPoolExecutor()
.