# 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 pypdevs.threadpool.ThreadPool(num_threads)

  Pool of threads consuming tasks from a queue

  __init__(num_threads)

    Constructor

    Parameters

      num_threads – number of threads to start

  addTask(func, *args, **kwargs)

    Add a task to the queue

    Parameters

      func – function to execute

class pypdevs.threadpool.Worker(tasks)

  Thread executing tasks from a given tasks queue

  __init__(tasks)

    Constructor

    Parameters

      tasks – queue containing tasks to execute

  run()

    Run the worker thread