Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
 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)
Exemple #5
0
 def waiter():
     try:
         list(gruvi.as_completed(futures, timeout=0.01))
     except Timeout as e:
         exceptions.append(e)
Exemple #6
0
 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)
Exemple #7
0
 def waiter():
     for fut in gruvi.as_completed(futures, count=2):
         result.append(fut)
Exemple #8
0
 def waiter():
     try:
         list(gruvi.as_completed(futures, timeout=0.01))
     except Timeout as e:
         exceptions.append(e)
Exemple #9
0
 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)
Exemple #10
0
 def waiter():
     for fut in gruvi.as_completed(futures, count=2):
         result.append(fut)