'Wait for all threads to end to avoid contamination between each tests.'

def tearDown(self):

    for (key, worker) in _thread_by_func.iteritems():
        while worker.is_alive():
            time.sleep(0.2)
    for key in _thread_by_func.keys():
        del _thread_by_func[key]
