'Wait until all tasks in the self._inqueue have been processed (the queue
has size == 0) and then call terminate on the Pool.
I know this is not the best way of doing it, but had some dead-lock
issues with:
self.close()
self.join()
:param timeout: Wait up to timeout seconds for the queues to be empty'

def finish(self, timeout=120):

    delay = 0.1
    for _ in xrange(int((timeout / delay))):
        if ((self._inqueue.qsize() == 0) and (self._outqueue.qsize() == 0) and (self._taskqueue.qsize() == 0)):
            break
        time.sleep(delay)
    self.terminate()
    self.join()
