Threadpool
A threadpool to process incomming messages over MPI with a fixed number of
(already running) threads.
Based on threadpool implementation found at http://stackoverflow.com/
questions/3033952/python-thread-pool-similar-to-the-multiprocessing-pool
-
class
threadpool.ThreadPool(num_threads)[source]
Pool of threads consuming tasks from a queue
-
__init__(num_threads)[source]
Constructor
| Parameters: | num_threads – number of threads to start |
-
addTask(func, *args, **kwargs)[source]
Add a task to the queue
| Parameters: | func – function to execute |
-
class
threadpool.Worker(tasks)[source]
Thread executing tasks from a given tasks queue
-
__init__(tasks)[source]
Constructor
| Parameters: | tasks – queue containing tasks to execute |
-
run()[source]
Run the worker thread