def test_partial(self): futures = [Future() for i in range(100)] futures[0].set_result(None) count = 0 for fut in gruvi.as_completed(futures, 10): self.assertEqual(fut, futures[count]) count += 1 futures[count].set_result(None) self.assertEqual(count, 10) for fut in futures: self.assertIsNone(fut._callbacks)
def test_partial(self): futures = [Future() for i in range(100)] futures[0].set_result(None) count = 0 for fut in gruvi.as_completed(futures, 10): self.assertEqual(fut, futures[count]) count += 1 futures[count].set_result(None) self.assertEqual(count, 10) for fut in futures: self.assertFalse(fut._callbacks)
def test_order(self): futures = [Future() for i in range(100)] order = list(range(len(futures))) random.shuffle(order) futures[order[0]].set_result(None) count = 0 for fut in gruvi.as_completed(futures): self.assertEqual(fut, futures[order[count]]) count += 1 if count < len(order): futures[order[count]].set_result(None) self.assertEqual(count, len(futures)) for fut in futures: self.assertFalse(fut._callbacks)
def test_order(self): futures = [Future() for i in range(100)] order = list(range(len(futures))) random.shuffle(order) futures[order[0]].set_result(None) count = 0 for fut in gruvi.as_completed(futures): self.assertEqual(fut, futures[order[count]]) count += 1 if count < len(order): futures[order[count]].set_result(None) self.assertEqual(count, len(futures)) for fut in futures: self.assertIsNone(fut._callbacks)
def waiter(): try: list(gruvi.as_completed(futures, timeout=0.01)) except Timeout as e: exceptions.append(e)
def test_timeout(self): futures = [Future() for i in range(10)] self.assertRaises(Timeout, lambda: list(gruvi.as_completed(futures, timeout=0.01))) for fut in futures: self.assertFalse(fut._callbacks)
def waiter(): for fut in gruvi.as_completed(futures, count=2): result.append(fut)
def test_timeout(self): futures = [Future() for i in range(10)] self.assertRaises( Timeout, lambda: list(gruvi.as_completed(futures, timeout=0.01))) for fut in futures: self.assertIsNone(fut._callbacks)