'Test that a \'reset\' on a barrier frees the waiting threads'

def test_reset(self):

    results1 = []
    results2 = []
    results3 = []
    def f():
        i = self.barrier.wait()
        if (i == (self.N // 2)):
            while (self.barrier.n_waiting < (self.N - 1)):
                time.sleep(0.001)
            self.barrier.reset()
        else:
            try:
                self.barrier.wait()
                results1.append(True)
            except threading.BrokenBarrierError:
                results2.append(True)
        self.barrier.wait()
        results3.append(True)
    self.run_threads(f)
    self.assertEqual(len(results1), 0)
    self.assertEqual(len(results2), (self.N - 1))
    self.assertEqual(len(results3), self.N)
